Skip to content

Instantly share code, notes, and snippets.

@jaypowley
Created December 28, 2018 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaypowley/4947dc35b2c10b5f23e8d02ed5714a25 to your computer and use it in GitHub Desktop.
Save jaypowley/4947dc35b2c10b5f23e8d02ed5714a25 to your computer and use it in GitHub Desktop.
F# FizzBuzz
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