Created
July 24, 2019 14:57
-
-
Save egroj97/be2775e0fffd437fc37099c706538c50 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
# All the primes... | |
constant p = [ (1..∞).grep(&is-prime) ]; | |
# The definitions of "strong" and "weak"... | |
sub strong (\n) { n > 0 && p[n] > p[n-1, n+1].sum/2 } | |
sub weak (\n) { n > 0 && p[n] < p[n-1, n+1].sum/2 } | |
# All the strong and weak primes... | |
constant strong-p = p.kv.map: ->\n,\pₙ {pₙ if strong n}; | |
constant weak-p = p.kv.map: ->\n,\pₙ {pₙ if weak n}; | |
# Print out the first ten... | |
say 'strong primes: ', strong-p[^10]; | |
say 'weak primes: ', weak-p[^10]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment