Skip to content

Instantly share code, notes, and snippets.

@irfancharania
Last active August 29, 2015 14:11
Show Gist options
  • Save irfancharania/67f7265718e3313ff500 to your computer and use it in GitHub Desktop.
Save irfancharania/67f7265718e3313ff500 to your computer and use it in GitHub Desktop.
Fizzbuzz in F#
let FizzBuzz x =
match x % 3, x % 5 with
| 0, 0 -> "FizzBuzz"
| 0, _ -> "fizz"
| _, 0 -> "buzz"
| _ -> sprintf "%d" x
let n = 100
[1..n]
|> Seq.map (FizzBuzz)
|> Seq.fold(sprintf "%s %s") ""
|> printfn "%s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment