From 8c4b7ad7bd474c48af5bebdb566412d30101f28e Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 7 Mar 2022 13:56:37 +0100 Subject: Week 155: Perl solutions --- challenge-155/abigail/perl/ch-1.pl | 23 ++++++++++++++++++++ challenge-155/abigail/perl/ch-2.pl | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 challenge-155/abigail/perl/ch-1.pl create mode 100644 challenge-155/abigail/perl/ch-2.pl 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 -- cgit