Skip to content

Instantly share code, notes, and snippets.

@jrgcubano
Forked from tcshao/FizzBuzz.fsx
Created February 4, 2016 17:35
Show Gist options
  • Save jrgcubano/7343c4eebcc9a569045f to your computer and use it in GitHub Desktop.
Save jrgcubano/7343c4eebcc9a569045f to your computer and use it in GitHub Desktop.
FizzBuzz in F#
let fizzBuzz x =
match x with
| _ when (x % 15) = 0 -> "FizzBuzz"
| _ when (x % 3) = 0 -> "Fizz"
| _ when (x % 5) = 0 -> "Buzz"
| _ -> ""
let fizzBuzzTo max =
[1..max]
|> List.iter (fun number -> printfn "%d %s" number (fizzBuzz number))
|> ignore
fizzBuzzTo 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment