diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2021-08-15 09:52:31 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2021-08-15 09:52:31 +0800 |
| commit | 396867334ee4fe6295c5fa8415537f857e9b0063 (patch) | |
| tree | bdf8f820a337d7d1759a6d66c28074ab35f68fb3 | |
| parent | 85d81a12be37eba47cbad2cb4f8218d951436bec (diff) | |
| download | perlweeklychallenge-club-396867334ee4fe6295c5fa8415537f857e9b0063.tar.gz perlweeklychallenge-club-396867334ee4fe6295c5fa8415537f857e9b0063.tar.bz2 perlweeklychallenge-club-396867334ee4fe6295c5fa8415537f857e9b0063.zip | |
improve bound on ch-1.pl
| -rw-r--r-- | challenge-125/cheok-yin-fung/perl/ch-1.pl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/challenge-125/cheok-yin-fung/perl/ch-1.pl b/challenge-125/cheok-yin-fung/perl/ch-1.pl index 10fabf76ef..6258feda8a 100644 --- a/challenge-125/cheok-yin-fung/perl/ch-1.pl +++ b/challenge-125/cheok-yin-fung/perl/ch-1.pl @@ -7,7 +7,7 @@ use warnings; use v5.10.0; use experimental 'signatures'; use List::Util qw/max/; -use Test::More tests => 7; +use Test::More tests => 8; my $num = $ARGV[0] || 5; my @arr = pyth($num)->@*; @@ -37,7 +37,7 @@ sub pyth ($n) { } } - for my $b0 ($n+1..$n*$n) { + for my $b0 ($n+1..int ($n*$n-1)/2) { my $is_sq = $b0*$b0 + $n*$n; if (sqrt($is_sq) == int sqrt($is_sq)) { push @ans, [$n , $b0 ,sqrt($is_sq)]; @@ -55,3 +55,4 @@ ok scalar @{pyth(4)} == 1, "Number 4"; ok scalar @{pyth(5)} == 2, "Number 5"; ok scalar @{pyth(8)} == 2, "Number 8"; ok scalar @{pyth(13)} == 2, "Number 13"; +ok scalar @{pyth(5740)} == 44, "Number 5740" # oeis.org/A046081 |
