以下の内容はhttps://inamori.hateblo.jp/entry/20120706/p1より取得しました。


Windows PowerShellでProject Euler(11)

Problem 5

lcmを繰り返し適用するだけの問題です。lcmがgcmを使います。gcmはふつうに再帰で定義します。

function fold($f, $init) {
    begin   { $x = $init }
    process { $x = & $f $x $_ }
    end     { $x }
}

function gcd($m, $n) {
    if($n -eq 0) { $m } else { gcd $n ($m % $n) }
}

function lcm($m, $n) {
    $m / (gcd $m $n) * $n
}

1..20 | fold { lcm $args[0] $args[1] } 1



以上の内容はhttps://inamori.hateblo.jp/entry/20120706/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14