I tried to implement FizzBuzz in elixir. I think it works, but I have some weird behavior and it may be my environment. I can run the following .exs
file using elixir fizzbuzz.exs
and on the first run it works as you would expect. Even on the second run it would work as you would expect. However, if I wait 7 or 8 seconds and run it again, it will stop at 13, or maybe 14. It might even make it to 50. There really isn't anything too consistent about what I am experiencing. I've reproduced it on the first run, I've reproduced it after waiting two seconds between runs. I've even gone a few minutes without being able to reproduce it at all. Please help me...
IO.puts "Hello world from Elixir"
defmodule Fizzbuzz do
def run(max) do
run(1, max)
end
def run(n, max) do
if rem(n, 3) == 0 do
IO.puts "FIZZ"
end
if rem(n, 5) == 0 do
IO.puts "BUZZ"
end
if rem(n, 3) != 0 && rem(n, 5) != 0 do
IO.puts n
end
if n < max do
run(n + 1, max)
end
end
end
Fizzbuzz.run(100)
#: Elixir -v
Erlang/OTP 21 [erts-10.2] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]
Elixir 1.9.4 (compiled with Erlang/OTP 20)
:timer.sleep(1000)
afterFizzbuzz.run
, to see if something like that is going on. – Fenestra:timer.sleep(1000)
to the end of the script I am no longer able to reproduce my problem. I didn't like the pause at the end so I changed the value for sleep/1 to200
and I am still unable to reproduce the issue. – Possessedasdf
version manager? orIEx.configure(inspect: [limit: :infinity])
? – Cordellcorder