Created
December 28, 2018 01:01
-
-
Save jaypowley/4947dc35b2c10b5f23e8d02ed5714a25 to your computer and use it in GitHub Desktop.
F# FizzBuzz
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 numbers = [ 1..100 ] | |
let isDivisibleBy3 x = | |
match x % 3 with | |
| 0 -> true | |
| _ -> false | |
let isDivisibleBy5 x = | |
match x % 5 with | |
| 0 -> true | |
| _ -> false | |
let isDivisibleBy3And5 x = (isDivisibleBy3 x && isDivisibleBy5 x) | |
let fizzbuzz x = | |
match x with | |
| (y) when isDivisibleBy3And5 y -> printfn "FizzBuzz" | |
| (y) when isDivisibleBy3 y -> printfn "Fizz" | |
| (y) when isDivisibleBy5 y -> printfn "Buzz" | |
| _ -> printfn "%d" x | |
for i in numbers do | |
fizzbuzz i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment