Created
December 5, 2023 03:43
-
-
Save RyushiAok/ee204d0098ae15f6e0c4048d28f4046a to your computer and use it in GitHub Desktop.
FsFizzBuzz.fsx
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 (|Fizz|_|) n = if n % 3 = 0 then Some "Fizz" else None | |
let (|Buzz|_|) n = if n % 5 = 0 then Some "Buzz" else None | |
let (|FizzBuzz|_|) n = | |
if n % 15 = 0 then Some "FizzBuzz" else None | |
let fizzBuzz = | |
function | |
| FizzBuzz fizzbuzz -> fizzbuzz | |
| Fizz fizz -> fizz | |
| Buzz buzz -> buzz | |
| n -> n.ToString() | |
[ 1..100 ] |> List.iter (fizzBuzz >> printfn "%s") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment