Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
open System
//Taken from https://gist.github.com/rmunn/bc49d32a586cdfa5bcab1c3e7b45d7ac
let bitcount (n : int) =
let count2 = n - ((n >>> 1) &&& 0x55555555)
let count4 = (count2 &&& 0x33333333) + ((count2 >>> 2) &&& 0x33333333)
let count8 = (count4 + (count4 >>> 4)) &&& 0x0f0f0f0f
(count8 * 0x01010101) >>> 24
//Modified from other examples to actually state the 1 is not prime
let isPrime n =
if n < 2 then
false
else
let sqrtn n = int <| sqrt (float n)
seq { 2 .. sqrtn n } |> Seq.exists(fun i -> n % i = 0) |> not
[<EntryPoint>]
let main _ =
[1 .. 100] |> Seq.filter (bitcount >> isPrime) |> Seq.take 25 |> Seq.toList |> printfn "%A"
[888888877 .. 888888888] |> Seq.filter (bitcount >> isPrime) |> Seq.toList |> printfn "%A"
0 // return an integer exit code