use strict; use Stream; use Math::Pari qw(gcd); # We can test all the factors at once using the greatest common diviso +r algorithm. my @factors = @ARGV; my $test_number = 1; $test_number *= $_ for @factors; die "Must provide a list of non-zero factors\n" unless $test_number > +1; sub has_common_factor { gcd($_[0], $test_number) != 1 } my $integers = Stream::tabulate( sub { $_[0] }, 1); my $challenge = $integers->filter(\&has_common_factor); $challenge->show(50);
In reply to Re: Challenge: Another Infinite Lazy List
by tall_man
in thread Challenge: Another Infinite Lazy List
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |