by so-cal-schemer | 2025-08-04 10:24:35+00:00
Some notable examples:

(pulled from https://rosettacode.org/)

-------------------------------- [[ Scheme ]] (do ((i 1 (+ i 1))) ((> i 100)) (display (cond ((= 0 (modulo i 15)) "FizzBuzz") ((= 0 (modulo i 3)) "Fizz") ((= 0 (modulo i 5)) "Buzz") (else i))) (newline)) -------------------------------- [[ Python ]] for i in range(1, 101): if i % 15 == 0: print("FizzBuzz") elif i % 3 == 0: print("Fizz") elif i % 5 == 0: print("Buzz") else: print(i) -------------------------------- [[ Logo ]] to fizzbuzz :n output cond [ [[equal? 0 modulo :n 15] "FizzBuzz] [[equal? 0 modulo :n 5] "Buzz] [[equal? 0 modulo :n 3] "Fizz] [else :n] ] end repeat 100 [print fizzbuzz #] -------------------------------- [[ Racket ]] (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [ 3 "fizz"] [ 5 "buzz"] [ _ n]))) -------------------------------- [[ Arc ]] (for n 1 100 (prn:check (string (when (multiple n 3) 'Fizz) (when (multiple n 5) 'Buzz)) ~empty n)) ; check created string not empty, else return n -------------------------------- [[ Rust ]] fn main() { for i in 1..=100 { match (i % 3, i % 5) { (0, 0) => println!("fizzbuzz"), (0, _) => println!("fizz"), (_, 0) => println!("buzz"), (_, _) => println!("{}", i), } } } -------------------------------- [[ Julia ]] for i in 1:100 if i % 15 == 0 println("FizzBuzz") elseif i % 3 == 0 println("Fizz") elseif i % 5 == 0 println("Buzz") else println(i) end end -------------------------------- [[ Hy ]] (for [i (range 1 101)] (print (cond [(not (% i 15)) "FizzBuzz"] [(not (% i 5)) "Buzz"] [(not (% i 3)) "Fizz"] [True i]))) -------------------------------- [[ Crystal ]] 1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end -------------------------------- [[ Perl ]] for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; } -------------------------------- [[ Ruby ]] 1.upto(100) do |n| print "Fizz" if a = (n % 3).zero? print "Buzz" if b = (n % 5).zero? print n unless (a || b) puts end -------------------------------- [[ Prolog ]] fizzbuzz(X) :- X mod 15 =:= 0, !, write('FizzBuzz'). fizzbuzz(X) :- X mod 3 =:= 0, !, write('Fizz'). fizzbuzz(X) :- X mod 5 =:= 0, !, write('Buzz'). fizzbuzz(X) :- write(X). dofizzbuzz :-between(1, 100, X), fizzbuzz(X), nl, fail. dofizzbuzz. -------------------------------- [[ Haskell ]] fizzbuzz :: Int -> String fizzbuzz x | f 15 = "FizzBuzz" | f 3 = "Fizz" | f 5 = "Buzz" | otherwise = show x where f = (0 ==) . rem x main :: IO () main = mapM_ (putStrLn . fizzbuzz) [1 .. 100] -------------------------------- [[ OCaml ]] let fizzbuzz i = match i mod 3, i mod 5 with 0, 0 -> "FizzBuzz" | 0, _ -> "Fizz" | _, 0 -> "Buzz" | _ -> string_of_int i let _ = for i = 1 to 100 do print_endline (fizzbuzz i) done -------------------------------- [[ Nix ]] let fizzbuzz = { x ? 1 }: '' ${if (mod x 15 == 0) then "FizzBuzz" else if (mod x 3 == 0) then "Fizz" else if (mod x 5 == 0) then "Buzz" else (toString x)} '' + (if (x < 100) then fizzbuzz { x = x + 1; } else ""); in fizzbuzz { } -------------------------------- [[ Elixir ]] 1..100 |> Enum.map(fn i -> cond do rem(i,3\*5) == 0 -> "FizzBuzz" rem(i,3) == 0 -> "Fizz" rem(i,5) == 0 -> "Buzz" true -> i end end) |> Enum.each(fn i -> IO.puts i end) -------------------------------- [[ J ]] (":[^:(0=#@])Fizz`Buzz;@#~0=3 5&|)"0>:i.100 -------------------------------- [[ Forth ]] : .fizzbuzz ( n -- ) 0 pad c! dup 3 mod 0= if s" Fizz" pad place then dup 5 mod 0= if s" Buzz" pad +place then pad c@ if drop pad count type else . then ; : zz ( n -- ) 1+ 1 do i .fizzbuzz cr loop ; 100 zz -------------------------------- [[ Go ]] func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } } -------------------------------- [[ C ]] int main (void) { int i; for (i = 1; i <= 100; i++) { if (!(i % 15)) printf ("FizzBuzz"); else if (!(i % 3)) printf ("Fizz"); else if (!(i % 5)) printf ("Buzz"); else printf ("%d", i); printf("\n"); } return 0; } -------------------------------- [[ Java ]] public class FizzBuzz { public static void main(String[] args) { for (int number = 1; number <= 100; number++) { if (number % 15 == 0) { System.out.println("FizzBuzz"); } else if (number % 3 == 0) { System.out.println("Fizz"); } else if (number % 5 == 0) { System.out.println("Buzz"); } else { System.out.println(number); } } } } -------------------------------- [[ Scala ]] object FizzBuzz extends App { 1 to 100 foreach { n => println((n % 3, n % 5) match { case (0, 0) => "FizzBuzz" case (0, _) => "Fizz" case (_, 0) => "Buzz" case _ => n }) } }