forked from Sergio0694/FizzBuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.fs
More file actions
27 lines (24 loc) · 745 Bytes
/
Program.fs
File metadata and controls
27 lines (24 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(*
* FizzBuzz Implementation in F#
* Sergio0694 - October 20, 2019
*
* "Write a program that prints the numbers from 1 to 100. But for multiples of three print
* “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which
* are multiples of both three and five print “FizzBuzz”."
*)
let fizbuzz =
let rec f (i:int) : unit =
match i with
| 101 -> ()
| _ ->
match i with
| _ when i % 3 = 0 && i % 5 = 0 -> printfn "FizzBuzz"
| _ when i % 3 = 0 -> printfn "Fizz"
| _ when i % 5 = 0 -> printfn "Buzz"
| _ -> printfn "%i" i
f (i + 1)
f 1
[<EntryPoint>]
let main argv =
fizbuzz |> ignore
0