Language: Erlang Code:
Short version, generate a list (of strings and integers), don’t bother printing:
lists:map( fun( X ) -> case { X rem 3, X rem 5 } of { 0, 0 } -> "FizzBuzz"; { 0, _ } -> "Fizz"; { _, 0 } -> "Buzz"; _ -> X end end, lists:seq( 1, 100 ) ).
Full version, print one term per line. Here we have to convert integers to strings:
lists:foreach( fun( X ) -> io:format( "~s~n", [ case { X rem 3, X rem 5 } of { 0, 0 } -> "FizzBuzz"; { 0, _ } -> "Fizz"; { _, 0 } -> "Buzz"; _ -> integer_to_list(X) end ] ) end, lists:seq( 1, 100 ) ).
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Language: Erlang
Code:
Short version, generate a list (of strings and integers), don’t bother printing:
Full version, print one term per line. Here we have to convert integers to strings: