排列倍数
作者:Jonathan Scott Duff
https://projecteuler.net/problem=52
可以看出,数字 125874 及其两倍 251748 包含完全相同的数字,但顺序不同。
求最小的正整数 x,使得 2x、3x、4x、5x 和 6x 包含相同的数字。
源代码: prob052-duff.pl
use v6;
my $mag = 1; # current power of 10
my $n = $mag; # number to start searching from
loop {
my $s = (2*$n).comb.sort;
last if
$s eq (3*$n).comb.sort &&
$s eq (4*$n).comb.sort &&
$s eq (5*$n).comb.sort &&
$s eq (6*$n).comb.sort;
$n++;
if log10(6*$n).Int > log10(2*$n).Int {
$mag *= 10;
$n = $mag;
}
}
say $n;
Perl 6 示例