Created
December 31, 2020 11:51
-
-
Save fnshr/21bf09893480b4c7de90a8eea0dca6fe to your computer and use it in GitHub Desktop.
Find new year's days whose dates are prime numbers and whose previous dates are also prime numbers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("numbers") # to use "isPrime" function | |
| # Prepare dates | |
| year <- 1000:2999 | |
| nyeve <- as.integer(paste0(year, "1231")) | |
| ny <- as.integer(paste0(year + 1, "0101")) | |
| # Output | |
| bool_successive <- isPrime(nyeve) & isPrime(ny) | |
| cat(paste(nyeve[bool_successive], ny[bool_successive], sep = ", "), sep = "\n") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result