Fizz Buzz in F#

Published on 08 April 2026 (Updated: 08 April 2026)

Welcome to the Fizz Buzz in F# page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

module FizzBuzz =
    let (|DivisibleBy|_|) divisor number =
        if number % divisor = 0 then Some() else None

    let fizzBuzzOf number =
        match number with
        | DivisibleBy 3 & DivisibleBy 5 -> "FizzBuzz"
        | DivisibleBy 3 -> "Fizz"
        | DivisibleBy 5 -> "Buzz"
        | _ -> string number

    let printUpTo n =
        Seq.init n (fun i -> i + 1) |> Seq.map fizzBuzzOf |> Seq.iter (printfn "%s")

[<EntryPoint>]
let main _ =
    FizzBuzz.printUpTo 100
    0

Fizz Buzz in F# was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.