Cuban primes: Difference between revisions
Content added Content deleted
(the number of cuban primes to be listed has been changed (was a typo) from 100 to 200.) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example) |
||
Line 93: | Line 93: | ||
</pre> |
</pre> |
||
=={{header|Perl 6}}== |
|||
{{works with|Rakudo|2018.12}} |
|||
Not the most efficient, but concise, and good enough for this task. |
|||
<lang perl6>sub comma { $^i.flip.comb(3).join(',').flip } |
|||
my @cubans = lazy (1..Inf).hyper(:8degree).map({ ($_+1)³ - .³ }).grep: *.is-prime; |
|||
put @cubans[^100]».&comma».fmt("%8s").rotor(10).join: "\n"; |
|||
put ''; |
|||
put @cubans[99_999]., # zero indexed</lang> |
|||
{{out}} |
|||
<pre> 7 19 37 61 127 271 331 397 547 631 |
|||
919 1,657 1,801 1,951 2,269 2,437 2,791 3,169 3,571 4,219 |
|||
4,447 5,167 5,419 6,211 7,057 7,351 8,269 9,241 10,267 11,719 |
|||
12,097 13,267 13,669 16,651 19,441 19,927 22,447 23,497 24,571 25,117 |
|||
26,227 27,361 33,391 35,317 42,841 45,757 47,251 49,537 50,311 55,897 |
|||
59,221 60,919 65,269 70,687 73,477 74,419 75,367 81,181 82,171 87,211 |
|||
88,237 89,269 92,401 96,661 102,121 103,231 104,347 110,017 112,327 114,661 |
|||
115,837 126,691 129,169 131,671 135,469 140,617 144,541 145,861 151,201 155,269 |
|||
163,567 169,219 170,647 176,419 180,811 189,757 200,467 202,021 213,067 231,019 |
|||
234,361 241,117 246,247 251,431 260,191 263,737 267,307 276,337 279,991 283,669 |
|||
1,792,617,147,127</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |