Ludic numbers: Difference between revisions

Content added Content deleted
(Added Elixir)
Line 1,346: Line 1,346:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|rakudo|2015-09-18}}
This implementation has no arbitrary upper limit, since it can keep adding new rotors on the fly. It just gets slower and slower instead... <tt>:-)</tt>
This implementation has no arbitrary upper limit, since it can keep adding new rotors on the fly. It just gets slower and slower instead... <tt>:-)</tt>
<lang perl6>constant ludic = gather {
<lang perl6>constant @ludic = gather {
my @taken = take 1;
my @taken = take 1;
my @rotor;
my @rotor;

for 2..* -> $i {
for 2..* -> $i {
loop (my $j = 0; $j < @rotor; $j++) {
loop (my $j = 0; $j < @rotor; $j++) {
Line 1,364: Line 1,365:
}
}
}
}

say ludic[^25];
say @ludic[^25];
say "Number of Ludic numbers <= 1000: ", +(ludic ...^ * > 1000);
say "Number of Ludic numbers <= 1000: ", +(@ludic ...^ * > 1000);
say "Ludic numbers 2000..2005: ", ludic[1999..2004];
say "Ludic numbers 2000..2005: ", @ludic[1999..2004];

my \l250 = set ludic ...^ * > 250;
my \l250 = set @ludic ...^ * > 250;
say "Ludic triples < 250: ", gather
say "Ludic triples < 250: ", gather
for l250.keys -> $a {
for l250.keys.sort -> $a {
my $b = $a + 2;
my $b = $a + 2;
my $c = $a + 6;
my $c = $a + 6;
Line 1,377: Line 1,378:
}</lang>
}</lang>
{{out}}
{{out}}
<pre>1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107
<pre>(1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107)
Number of Ludic numbers <= 1000: 142
Number of Ludic numbers <= 1000: 142
Ludic numbers 2000..2005: 21475 21481 21487 21493 21503 21511
Ludic numbers 2000..2005: (21475 21481 21487 21493 21503 21511)
Ludic triples < 250: <1 3 7> <5 7 11> <11 13 17> <23 25 29> <41 43 47> <173 175 179> <221 223 227> <233 235 239></pre>
Ludic triples < 250: (<1 3 7> <5 7 11> <11 13 17> <23 25 29> <41 43 47> <173 175 179> <221 223 227> <233 235 239>)</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==