diff options
| author | 冯昶 <seaker@qq.com> | 2022-03-17 12:21:37 +0800 |
|---|---|---|
| committer | 冯昶 <seaker@qq.com> | 2022-03-17 12:21:37 +0800 |
| commit | cf12d1ad0715c7481e8a0a4e0ecdfb52146544cb (patch) | |
| tree | 60e5a2323d05eafab1f0a22f9acd95b041b92c67 /challenge-156/feng-chang | |
| parent | 0b002e38fd0ba0495fcc6efb8ab7dd50da4bb725 (diff) | |
| download | perlweeklychallenge-club-cf12d1ad0715c7481e8a0a4e0ecdfb52146544cb.tar.gz perlweeklychallenge-club-cf12d1ad0715c7481e8a0a4e0ecdfb52146544cb.tar.bz2 perlweeklychallenge-club-cf12d1ad0715c7481e8a0a4e0ecdfb52146544cb.zip | |
challenge 156, raku solutions
Diffstat (limited to 'challenge-156/feng-chang')
| -rwxr-xr-x | challenge-156/feng-chang/raku/ch-1.raku | 3 | ||||
| -rwxr-xr-x | challenge-156/feng-chang/raku/ch-2.raku | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/challenge-156/feng-chang/raku/ch-1.raku b/challenge-156/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..e9ffe88c2c --- /dev/null +++ b/challenge-156/feng-chang/raku/ch-1.raku @@ -0,0 +1,3 @@ +#!/bin/env raku + +put (1..∞).grep(*.base(2).comb.sum.is-prime)[^10]; diff --git a/challenge-156/feng-chang/raku/ch-2.raku b/challenge-156/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..a6bd9372fd --- /dev/null +++ b/challenge-156/feng-chang/raku/ch-2.raku @@ -0,0 +1,14 @@ +#!/bin/env raku + +unit sub MAIN(UInt:D \n); + +put +is-weird(n); + +sub proper-divisors(UInt:D \n) { (1..^n).grep({ n %% $_ }) } + +sub is-weird(UInt:D \n) { + my @d = proper-divisors(n); + my \和 = @d.sum; + + 和 > n and @d.combinations».sum.grep(* == 和 - n).elems == 0 +} |
