Last active
August 29, 2015 14:11
-
-
Save irfancharania/67f7265718e3313ff500 to your computer and use it in GitHub Desktop.
Fizzbuzz in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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