結果

問題 No.713 素数の和
ユーザー wotsushiwotsushi
提出日時 2018-07-23 21:40:49
言語 Elixir
(1.16.2)
結果
AC  
実行時間 639 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 55,276 KB
実行使用メモリ 49,864 KB
最終ジャッジ日時 2023-08-29 22:46:05
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 635 ms
49,460 KB
testcase_01 AC 628 ms
49,772 KB
testcase_02 AC 635 ms
49,180 KB
testcase_03 AC 639 ms
49,660 KB
testcase_04 AC 636 ms
49,396 KB
testcase_05 AC 634 ms
49,864 KB
testcase_06 AC 619 ms
49,564 KB
testcase_07 AC 629 ms
49,420 KB
testcase_08 AC 637 ms
49,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  defp prime?(n) do
    case n do
      1 -> false
      2 -> true
      _ -> Enum.all?(2..(n - 1), &(rem(n, &1) != 0))
    end
  end

  def main do
    n = IO.gets("") |> String.trim |> String.to_integer

    ans = 1..n |> Enum.filter(&prime?/1) |> Enum.sum

    IO.puts ans
  end
end
0