結果
問題 |
No.480 合計
|
ユーザー |
![]() |
提出日時 | 2018-11-16 22:28:56 |
言語 | Elixir (1.18.1) |
結果 |
AC
|
実行時間 | 622 ms / 2,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 994 ms |
コンパイル使用メモリ | 62,680 KB |
実行使用メモリ | 55,736 KB |
最終ジャッジ日時 | 2024-12-31 02:25:29 |
合計ジャッジ時間 | 15,595 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
defmodule Main do def getsAll(device \\ :stdio, prompt), do: getsAll(device, prompt, "") defp getsAll(device, prompt, input) do x = IO.gets(device, prompt) case x do {:error, _} -> x :eof -> input _ -> getsAll(device, prompt, input <> x) end end def sum(n), do: sum(n, 1) defp sum(n, acc) do case n do 1 -> acc _ -> sum(n - 1, acc + n) end end def main do inputs = getsAll(nil) |> String.split n = inputs |> Enum.at(0) |> String.to_integer IO.puts sum(n) end end