Skip to content

Instantly share code, notes, and snippets.

@colomon
Created October 13, 2010 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colomon/623953 to your computer and use it in GitHub Desktop.
Save colomon/623953 to your computer and use it in GitHub Desktop.
sub is-prime($a) {
return Bool::True if $a == 2;
! [||] $a <<%%<< (2, 3, *+2 ... * > $a.sqrt);
}
my @fib := (1, 1, *+* ... *);
my $cutoff = 227000;
my $least-prime = 0;
for @fib -> $f {
next if $f <= $cutoff;
say "checking $f";
next unless is-prime($f);
say $f;
$least-prime = $f;
last;
}
my $x = $least-prime + 1;
(2, 3, *+2 ... * > $x.sqrt).grep({ $x %% $^a && is-prime($a) }).perl.say;
say [+] (2, 3, *+2 ... * > $x.sqrt).grep({ $x %% $^a && is-prime($a) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment