diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2022-04-03 09:51:38 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2022-04-03 09:51:38 +0800 |
| commit | 28e89e8ad9b1250176d0700b3a4602ea8f162fce (patch) | |
| tree | 681f9b0ef15f7cb22f764ab90c8c3c0fe183503e /challenge-158 | |
| parent | e2dc8c813b1abcf9b9c1aa2518602af9050738f3 (diff) | |
| download | perlweeklychallenge-club-28e89e8ad9b1250176d0700b3a4602ea8f162fce.tar.gz perlweeklychallenge-club-28e89e8ad9b1250176d0700b3a4602ea8f162fce.tar.bz2 perlweeklychallenge-club-28e89e8ad9b1250176d0700b3a4602ea8f162fce.zip | |
further optimize
Diffstat (limited to 'challenge-158')
| -rw-r--r-- | challenge-158/cheok-yin-fung/dart/ch-2.dart | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/challenge-158/cheok-yin-fung/dart/ch-2.dart b/challenge-158/cheok-yin-fung/dart/ch-2.dart index 265cae1291..7d425e4584 100644 --- a/challenge-158/cheok-yin-fung/dart/ch-2.dart +++ b/challenge-158/cheok-yin-fung/dart/ch-2.dart @@ -17,10 +17,9 @@ void main(List<String> args) { spokes.add( rp_to_30[i] ); // skip 1 while (pp <= arg) { if (pp % 5 == 0) continue; // pp must be coprime to 2 and 3. - if (spokes.last <= sqrt(pp)) { + if (spokes.last < sqrt(pp)) { var k = ((spokes.last+1)/30).floor(); - for (; k*30 <= sqrt(pp); k++) - rp_to_30.forEach( (e) => spokes.add(e+k*30) ); + rp_to_30.forEach( (e) => spokes.add(e+k*30) ); } y++; if (spokes.any( (d) => pp % d == 0 )) { |
