Skip to content

Commit

Permalink
Add A000959 / Lucky
Browse files Browse the repository at this point in the history
It is really slow at the moment, but the logic is very
lightweight. I'm suspecting an issue in rakudo.
  • Loading branch information
AlexDaniel committed Jul 6, 2019
1 parent f8f2e1d commit fd15438
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Math/Sequences/Integer.pm
Expand Up @@ -418,7 +418,17 @@ our @A000796 is export = lazy Pi-digits;
# A000798 / quasi-orders or topologies
our @A000798 is export = 1, &NOSEQ ... *;
# A000959 / Lucky
our @A000959 is export = 1, &NOSEQ ... *;
# kickstart the sequence manually to make sure we don't rotorize with 0 elems
my $lucky-iterator = ((1…∞).rotor(1 => 1).flat.rotor(2 => 1).flat).skip(2).iterator;
our @A000959 is export = 1, 3,
{
my $val = $lucky-iterator.pull-one;
$lucky-iterator = Seq.new($lucky-iterator) # rewrap
.rotor( $val - 1 - 2 - ++$ => 1, # some elems are already behind
($val - 1 => 1) xx ∞)
.flat.iterator;
$val
} ... *;
# A000961 / prime powers
our @A000961 is export = 1, &NOSEQ ... *;
# A000984 / binomial(2n,n)
Expand Down

0 comments on commit fd15438

Please sign in to comment.