Skip to content

Instantly share code, notes, and snippets.

@ElvisLives
Created August 1, 2016 21:21
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 ElvisLives/19cc3806f694a11ea3a7a10480b8f2f6 to your computer and use it in GitHub Desktop.
Save ElvisLives/19cc3806f694a11ea3a7a10480b8f2f6 to your computer and use it in GitHub Desktop.
module Fizzbuzz
open System
let rangeOfNumbers = [1..100]
let isDivisible number x = (x % number) = 0
let fizzAndBuzz x = (isDivisible(3) x && isDivisible(5) x)
let answer (number:int) =
match number with
| x when fizzAndBuzz number = true -> printfn "FizzBuzz"
| x when isDivisible(3) x = true -> printfn "Fizz"
| x when isDivisible(5) x = true -> printfn "Buzz"
| _ -> printfn "%A" number
for number in rangeOfNumbers do
answer number
Console.ReadKey() |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment