Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find new year's days whose dates are prime numbers and whose previous dates are also prime numbers.
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")
@fnshr

This comment has been minimized.

Copy link
Owner Author

@fnshr fnshr commented Dec 31, 2020

Result

  • 10001231, 10010101
  • 10181231, 10190101
  • 10511231, 10520101
  • 10841231, 10850101
  • 11261231, 11270101
  • 11531231, 11540101
  • 11591231, 11600101
  • 11651231, 11660101
  • 11861231, 11870101
  • 11981231, 11990101
  • 12371231, 12380101
  • 14681231, 14690101
  • 15131231, 15140101
  • 15551231, 15560101
  • 16001231, 16010101
  • 16211231, 16220101
  • 17471231, 17480101
  • 18101231, 18110101
  • 18281231, 18290101
  • 18911231, 18920101
  • 19301231, 19310101
  • 19721231, 19730101
  • 19781231, 19790101
  • 19871231, 19880101
  • 20201231, 20210101
  • 20291231, 20300101
  • 21611231, 21620101
  • 23831231, 23840101
  • 24131231, 24140101
  • 24371231, 24380101
  • 25331231, 25340101
  • 25811231, 25820101
  • 26021231, 26030101
  • 26501231, 26510101
  • 26891231, 26900101
  • 27761231, 27770101
  • 29321231, 29330101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment