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 fizzbuzz(n) do cond do rem(n, 3) == 0 and rem(n, 5) == 0 -> "FizzBuzz" rem(n, 3) == 0 -> "Fizz" rem(n, 5) == 0 -> "Buzz" true -> n end end def main do inputs = getsAll(nil) |> String.split n = inputs |> Enum.at(0) |> String.to_integer for x <- 1..n, do: IO.puts fizzbuzz(x) end end