强大的数字计数
作者:Moritz Lenz
https://projecteuler.net/problem=63
5 位数 16807=7^5 也是一个五次幂。同样,9 位数 134217728=8^9 是一个九次幂。
有多少个 n 位正整数也是 n 次幂?
use v6;
sub MAIN(Bool :$verbose = False) {
my $count = 0;
for 1..9 -> $x {
for 1..200 -> $y {
if ($x**$y).chars == $y {
say "$x**$y" if $verbose;
$count++;
}
}
}
say $count;
say "missing bigint support: answer should be 49" if $verbose;
}
Perl 6 示例