Created
March 10, 2024 19:10
-
-
Save krishnanraman/427ad599b68063c80e9a5fa76882d045 to your computer and use it in GitHub Desktop.
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
# Find x such that x+1, 2x+3,3x+5 and 4x+7 are prime. | |
library(DescTools) | |
# This works | |
subset(expand.grid(x=1:1000),IsPrime(x+1) & IsPrime(2*x+3) & IsPrime(3*x+5) & IsPrime(4*x+7)) | |
# Alternate solution | |
which(mapply(function(x) IsPrime(x+1) & IsPrime(2*x+3) & IsPrime(3*x+5) & IsPrime(4*x+7), 1:1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment