aboutsummaryrefslogtreecommitdiff
path: root/challenge-246
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-12-11 02:32:47 +0000
committerGitHub <noreply@github.com>2023-12-11 02:32:47 +0000
commit5cfdb554ce05d3985819b37d9180780e7cc50d75 (patch)
tree3657e4facf361bf172006a6f454400db874657a3 /challenge-246
parent2a030270dd9481dd21cb29bc4446409b545f641f (diff)
parent9df9687f9b58369126ea4a5e779274af3b1d04c0 (diff)
downloadperlweeklychallenge-club-5cfdb554ce05d3985819b37d9180780e7cc50d75.tar.gz
perlweeklychallenge-club-5cfdb554ce05d3985819b37d9180780e7cc50d75.tar.bz2
perlweeklychallenge-club-5cfdb554ce05d3985819b37d9180780e7cc50d75.zip
Merge pull request #9222 from steve-g-lynn/branch-for-challenge-246
sorry bugfix ch-2
Diffstat (limited to 'challenge-246')
-rwxr-xr-xchallenge-246/steve-g-lynn/perl/ch-2.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/challenge-246/steve-g-lynn/perl/ch-2.pl b/challenge-246/steve-g-lynn/perl/ch-2.pl
index 12d59609b8..e8606bf93a 100755
--- a/challenge-246/steve-g-lynn/perl/ch-2.pl
+++ b/challenge-246/steve-g-lynn/perl/ch-2.pl
@@ -25,7 +25,8 @@ local *linear_recurrence_2 = sub {
(scalar(grep {$_==0} @_)==5) && (return 1);
(($_[0]==0) && ($_[1]==0) && ($_[2] != 0)) && (return 0);
(($_[1]==0) && ($_[2]==0) && ($_[3] != 0)) && (return 0);
- (($_[2]==0) && ($_[3]==0) && ($_[4] != 0)) && (return 0);
+ (($_[2]==0) && ($_[3]==0) && ($_[4] != 0)) && (return 0);
+ (($_[0] != 0) && ($_[1]==0) && ($_[2]==0)) && (return 1); #-- must be of the form (x,0,0,0,0)
#-- if hcf of 1st 2 elements does not divide into all others, reject
if (($_[0] != 0) && ($_[1] != 0)){
@@ -78,6 +79,7 @@ local *linear_recurrence_2 = sub {
print "Ex1 1,1,2,3,5: ", &linear_recurrence_2(1,1,2,3,5); #1
print "Ex2 4,2,4,5,7: ", &linear_recurrence_2(4,2,4,5,7); #0
print "Ex3 4,1,2,-3,8: ", &linear_recurrence_2(4,1,2,-3,8); #1
+print "(1,0,0,0,0): ",&linear_recurrence_2(1,0,0,0,0); #1 [p=q=0]
print "--------------";
print "";