Skip to content

Instantly share code, notes, and snippets.

@eibrahim
Created February 2, 2016 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eibrahim/fb4a7af60b34b47bb480 to your computer and use it in GitHub Desktop.
Save eibrahim/fb4a7af60b34b47bb480 to your computer and use it in GitHub Desktop.
Fizzbuzz without conditional logic
def fizzbuzzNoCond n do
_fizzbuzzNoCondRange 1..n
end
defp _fizzbuzzNoCondRange(b..b) do
_fizzbuzzNoCond rem(b,3), rem(b,5), b
end
defp _fizzbuzzNoCondRange(a..b) do
_fizzbuzzNoCond rem(a,3), rem(a,5), a
_fizzbuzzNoCondRange (a+1)..b
end
defp _fizzbuzzNoCond 0,0,_ do IO.puts "fizzbuzz" end
defp _fizzbuzzNoCond 0,_,_ do IO.puts "fizz" end
defp _fizzbuzzNoCond _,0,_ do IO.puts "buzz" end
defp _fizzbuzzNoCond _,_,c do IO.puts c end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment