diff options
| author | drbaggy <js5@sanger.ac.uk> | 2022-06-06 22:38:47 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2022-06-06 22:38:47 +0100 |
| commit | d21729c11befcb9b09747e8ae7d79bd3d8d69744 (patch) | |
| tree | 4f66196332f790bc166df59ff6231ae7478f511c /challenge-168/james-smith | |
| parent | a03c1c66ba10580ecba32c5aa5d413cd69092b49 (diff) | |
| download | perlweeklychallenge-club-d21729c11befcb9b09747e8ae7d79bd3d8d69744.tar.gz perlweeklychallenge-club-d21729c11befcb9b09747e8ae7d79bd3d8d69744.tar.bz2 perlweeklychallenge-club-d21729c11befcb9b09747e8ae7d79bd3d8d69744.zip | |
add in the next 12 perrin primes using big int support
Diffstat (limited to 'challenge-168/james-smith')
| -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"; |
