メインメニューを開く

差分

素数

817 バイト追加, 2014年9月6日 (土) 09:57
外部リンクを追加、その他微調整
'''素数'''とは、1とその数でしか割り切れない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>
 
== 外部リンク ==
* [http://www.amazon.co.jp/dp/4873101565 Amazon.co.jp: 素数表150000個: 真実のみを記述する会: 本]
* [http://pn.ideeile.com/ 素数判定| Project IDEEILE]
* [http://www.primegrid.com/ PrimeGrid]
==関連項目==
* [[合成数]]
* [[素因数分解]]
* [[対お姉ちゃん用決戦部隊、通称チマメ隊]]
匿名利用者