結果

問題 No.713 素数の和
ユーザー iwotiwot
提出日時 2020-06-13 15:49:20
言語 F#
(F# 4.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 4,634 ms
コンパイル使用メモリ 162,144 KB
実行使用メモリ 25,096 KB
最終ジャッジ日時 2023-09-07 19:07:18
合計ジャッジ時間 6,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
23,140 KB
testcase_01 AC 84 ms
23,052 KB
testcase_02 AC 86 ms
23,124 KB
testcase_03 AC 85 ms
23,100 KB
testcase_04 AC 86 ms
25,096 KB
testcase_05 AC 85 ms
20,928 KB
testcase_06 AC 86 ms
20,928 KB
testcase_07 AC 87 ms
23,008 KB
testcase_08 AC 86 ms
22,968 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let isPrime n =
    let limit = n |> float |> sqrt |> ceil |> int
    let rec check i =
        if i > limit then true elif n % i = 0 then false else check (i+1)
    if n > 2 then check 2 else 2 = n

let n = stdin.ReadLine().Trim() |> int

let result = seq { for n in 2 .. n do n } |> Seq.filter isPrime |> Array.ofSeq |> Array.sum

printfn "%d" result
0