diff options
Diffstat (limited to 'challenge-168')
| -rw-r--r-- | challenge-168/james-smith/perl/ch-1.pl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/challenge-168/james-smith/perl/ch-1.pl b/challenge-168/james-smith/perl/ch-1.pl index e8f0ab5d01..2f25fc5369 100644 --- a/challenge-168/james-smith/perl/ch-1.pl +++ b/challenge-168/james-smith/perl/ch-1.pl @@ -4,6 +4,7 @@ use strict; use warnings; use feature qw(say); use Math::Prime::Util qw(is_prime); +use Math::BigInt; ## This is straight forward. ## In each interation of the loop, we remove the lowest number of the triple, @@ -14,6 +15,14 @@ use Math::Prime::Util qw(is_prime); ## then we restart the loop with redo, if not we display the number and ## continue until we have displayed the first 13 perrin primes. +say "\nWith normal ints (first 25)\n\n"; my ($r,$s,$t)=(3,0,2); -($r,$s,$t)=($s,$t,$r+$s), is_prime($t) && $t!=$s ? (say $t) : (redo) for 1..13 +($r,$s,$t)=($s,$t,$r+$s), is_prime($t) && $t!=$s ? (say $t) : (redo) for 1..13; +## Now with big ints... +say "\n\nWith big ints (first 25)\n\n"; + +($r,$s,$t)=(3,0,Math::BigInt->new(2)); +($r,$s,$t)=($s,$t,$r+$s), is_prime($t) && $t!=$s ? (say $t) : (redo) for 1..25; + +say "\n"; |
