「素数」の版間の差分

imported>MikeCAT
作成
 
2行目: 2行目:


==素数判定==
==素数判定==
=== [[F Sharp|F#]]による記述例 ===
<source lang="fsharp">
let isPrime (number : bigint) =
    match number with
        | _ -> seq { bigint(2) .. bigint(sqrt(float number))}
        |> Seq.exists (fun x -> if (number % x = bigint(0)) then true else false)
        |> not
let primes =
    Seq.initInfinite (fun i -> i + 2) //need to skip 0 and 1 for isPrime
    |> Seq.map (fun i -> bigint(i))
    |> Seq.filter isPrime
printfn "%A" primes;;
</source>
===愚直な方法===
===愚直な方法===
<source lang="c">
<source lang="c">