use Math::BigFloat; use strict; use warnings; Math::BigFloat->accuracy(400); # the length of the prime to find in e my $prime_length = $ARGV[0] || 10; # build e (1/0! + 1/1! + 1/2! + 1/3! + ... + 1/125!) my $e = do { my $t = Math::BigFloat->new; $t += 1/Math::BigFloat->new($_)->bfac for 0..125; $t->bstr }; # grab substrings for (0 .. length($e) - $prime_length) { my $potential = substr $e, $_, $prime_length; print "found prime $potential \@ position $_\n" and last if is_prime($potential); } sub is_prime { my ($p) = @_; $p % $_ == 0 and return for 2, 3 .. sqrt($p); # 2, 3 .. sqrt($p) is my trick return 1; }