diff options
| author | Abigail <abigail@abigail.freedom.nl> | 2022-03-07 13:56:37 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.freedom.nl> | 2022-03-07 14:16:11 +0100 |
| commit | 8c4b7ad7bd474c48af5bebdb566412d30101f28e (patch) | |
| tree | 046247c5e90ba9ee8e6f08a55c99490380a00f1f | |
| parent | c7a6466970fa9b0584a18785a4e80df61ffc3bf9 (diff) | |
| download | perlweeklychallenge-club-8c4b7ad7bd474c48af5bebdb566412d30101f28e.tar.gz perlweeklychallenge-club-8c4b7ad7bd474c48af5bebdb566412d30101f28e.tar.bz2 perlweeklychallenge-club-8c4b7ad7bd474c48af5bebdb566412d30101f28e.zip | |
Week 155: Perl solutions
| -rw-r--r-- | challenge-155/abigail/perl/ch-1.pl | 23 | ||||
| -rw-r--r-- | challenge-155/abigail/perl/ch-2.pl | 44 |
2 files changed, 67 insertions, 0 deletions
diff --git a/challenge-155/abigail/perl/ch-1.pl b/challenge-155/abigail/perl/ch-1.pl new file mode 100644 index 0000000000..30368a8a16 --- /dev/null +++ b/challenge-155/abigail/perl/ch-1.pl @@ -0,0 +1,23 @@ +#!/opt/perl/bin/perl + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-155 +# + +# +# Run as: perl ch-1.pl +# + +# +# Oh, gosh. Another "get the first N (with N fixed) numbers from +# an OEIS sequence". (Sequence A046066). And once again, dealing +# with prime numbers. Utterly fucking boring. +# + +# +# We assume Reo F. Fortune's conjecture is true (which it is for +# the first 1000 values of the sequence, and we only need 8) +# + +use ntheory":all";$p=$o=1;do{$o*=($m=$p=next_prime$p);$m=next_prime$m until +is_prime($o+$m);$f{$m}=1}until%f==8;$\=$/;$,=$";print sort{$a<=>$b}keys%f diff --git a/challenge-155/abigail/perl/ch-2.pl b/challenge-155/abigail/perl/ch-2.pl new file mode 100644 index 0000000000..28726366f4 --- /dev/null +++ b/challenge-155/abigail/perl/ch-2.pl @@ -0,0 +1,44 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-155 +# + +# +# Run as: perl ch-2.pl +# + +# +# So, we just want *ONE*, fixed, number from an OEIS sequence +# (Sequence A001175). +# + +# +# From the OEIS page of this sequence: +# +# Index the Fibonacci numbers so that 3 is the fourth number. If +# the modulo base is a Fibonacci number (>=3) with an even index, the +# period is twice the index. If the base is a Fibonacci number (>=5) +# with an odd index, the period is 4 times the index. - Kerry Mitchell, +# Dec 11 2005 +# +# We have a module base of 3. 3 is a Fibonnacci number, is >= 3, and +# is on index 4. 4 is even. Hence, the third Pisano period is 8. +# +# Which leaves us exactly nothing to compute. (Unless one needs a +# calculator to double 4). +# +# I guess the good thing is, we don't have to calculate Fibonacci +# numbers, like we've done a gazillion times recently. +# + +say 8 |
