Repository: zenware/FizzBuzz
Branch: master
Commit: 6045387c9a9f
Files: 107
Total size: 50.5 KB
Directory structure:
gitextract_1p_39tyn/
├── .gitignore
├── Elm.elm
├── Haxe.hx
├── Jasmin.j
├── PowerShell.ps1
├── README.md
├── ada_fizzbuzz.adb
├── apl.apl
├── applescript.applescript
├── arnoldc.arnoldc
├── assembly.asm
├── awk.awk
├── b.b
├── batch.bat
├── batsh.batsh
├── bc.bc
├── beta.bet
├── brainfuck.bf
├── buzzfizz.buzzfizz
├── c++.cpp
├── c.c
├── cesil.csl
├── chapel.chpl
├── clisp.lisp
├── clojure.clj
├── cobol.cbl
├── coffeescript.coffee
├── commodore_basic.bas
├── crystal.cr
├── csharp.cs
├── csharp10.cs
├── cuneiform.cfl
├── d.d
├── dafny.dfy
├── dart.dart
├── dc.dc
├── delphi.delphi
├── eiffel.e
├── elisp.el
├── elixir.exs
├── enkelt.e
├── escript.erl
├── forth.fth
├── fortran.f90
├── fsharp.fs
├── gamemakerlanguage.gml
├── gdscript.gd
├── go.go
├── groovy.groovy
├── haskell.hs
├── holyc.HC
├── hoon.hoon
├── io.io
├── j.j
├── java.java
├── javascript.js
├── julia.jl
├── kotlin.kt
├── labyrinth.lab
├── lobster.lobster
├── lolcode.lol
├── lolpython.lol
├── lua.lua
├── matlab.m
├── mercury.m
├── mysql.sql
├── nim.nim
├── objc.m
├── ocaml.ml
├── octave.m
├── pascal.p
├── pawn.p
├── perl.pl
├── perl6.pl
├── php.php
├── pinecone.pn
├── pony.pony
├── postgresql.sql
├── potigol.poti
├── processing.pde
├── prolog.pl
├── pyret.arr
├── python.py
├── python2.py
├── python3.py
├── r.R
├── racket.rkt
├── rockstar.rock
├── ruby.rb
├── rust.rs
├── sassy-css.scss
├── scala.scala
├── scheme.scm
├── scilab.sce
├── sed.sh
├── shell.sh
├── spwn.spwn
├── sqlite3.sql
├── swift.swift
├── tcl.tcl
├── text.txt
├── typescript.ts
├── vala.vala
├── visualbasic.vb
├── whitespace.wh
├── zig.zig
└── zinc.zn
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.DS_Store
*.swp
*~
================================================
FILE: Elm.elm
================================================
import Html exposing (Html, div, text)
fizzbuzz : Int -> List (Html a)
fizzbuzz to =
let
current =
case ( to % 3, to % 5 ) of
( 0, 0 ) ->
"FizzBuzz"
( 0, _ ) ->
"Fizz"
( _, 0 ) ->
"Buzz"
_ ->
toString to
in
case to of
0 ->
[]
_ ->
fizzbuzz (to - 1) ++ [ div [] [ text current ] ]
main : Html a
main =
div [] (fizzbuzz 100)
================================================
FILE: Haxe.hx
================================================
class Haxe {
static function main() {
for (num in 0...100)
{
if (num % 15 == 0) {
trace("FizzBuzz");
} else if (num % 5 == 0) {
trace("Buzz");
} else if (num % 3 == 0) {
trace("Fizz");
} else {
trace(num);
}
}
}
}
================================================
FILE: Jasmin.j
================================================
.class public Jasmin
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit locals 1
.limit stack 2
iconst_0
istore_0
loop:
iload_0
ldc 15
irem
ifeq fizzbuzz
iload_0
ldc 5
irem
ifeq buzz
iload_0
ldc 3
irem
ifeq fizz
getstatic java/lang/System/out Ljava/io/PrintStream;
iload_0
invokevirtual java/io/PrintStream/println(I)V
goto increment
fizzbuzz:
ldc "FizzBuzz"
goto stringprint
fizz:
ldc "Fizz"
goto stringprint
buzz:
ldc "Buzz"
goto stringprint
stringprint:
getstatic java/lang/System/out Ljava/io/PrintStream;
swap
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
goto increment
increment:
iinc 0 1
iload_0
ldc 100
if_icmple loop
return
.end method
================================================
FILE: PowerShell.ps1
================================================
for($i=1; $i -le 100; $i++)
{
if ($i % 3 -eq 0)
{
Write-Host -NoNewline "Fizz"
}
if ($i % 5 -eq 0)
{
Write-Host -NoNewline "Buzz"
}
if (($i % 5 -ne 0) -and ($i % 3 -ne 0))
{
Write-Host -NoNewline "$i"
}
Write-Host "`r" #Carriage return
}
================================================
FILE: README.md
================================================
# FizzBuzz
FizzBuzz in every programming language, inspired by [hello-world](https://github.com/leachim6/hello-world)
I added a file text.txt, containing the expected output, partly as a joke on the filenaming convention used in this repo.
Also as a useful tool to compare program output, I noticed there is some old code I wrote that needs to be patched.
Hopefully it will also be useful for building in some sort of continuous integration testing.
Hopefully I can include a list of other similar projects here.
* [MIT-licensed FizzBuzz](https://github.com/shlomif/fizz-buzz) - in several languages, with an explicit licence, and a test suite.
================================================
FILE: ada_fizzbuzz.adb
================================================
-- Note: GNAT complains if the unit is simply named "Ada" since that is a system
-- unit. gnatmake silently refuses to do anything.
with Ada.Text_IO;
procedure Ada_FizzBuzz is
package IO renames Ada.Text_IO;
function FizzBuzz(N : Integer) return String is
begin
if N mod 3 = 0 and N mod 5 = 0 then
return "FizzBuzz";
elsif N mod 3 = 0 then
return "Fizz";
elsif N mod 5 = 0 then
return "Buzz";
else
return Integer'Image(N)(2 .. Integer'Image(N)'Last);
end if;
end FizzBuzz;
begin
for I in Integer range 1 .. 100 loop
IO.Put_Line(FizzBuzz(I));
end loop;
end Ada_FizzBuzz;
================================================
FILE: apl.apl
================================================
{('FizzBuzz' 'Fizz' 'Buzz',⍵)[(0=15 3 5|⍵)⍳1]}¨⍳100
================================================
FILE: applescript.applescript
================================================
#!/usr/bin/osascript
on fizzbuzz(i)
if i mod 15 is 0 then
return "FizzBuzz"
else if i mod 3 is 0 then
return "Fizz"
else if i mod 5 is 0 then
return "Buzz"
else
return i as string
end if
end fizzbuzz
repeat with i from 1 to 100
log fizzbuzz(i) -- Print to stdout
end repeat
================================================
FILE: arnoldc.arnoldc
================================================
IT'S SHOWTIME
HEY CHRISTMAS TREE limit
YOU SET US UP 100
HEY CHRISTMAS TREE index
YOU SET US UP 1
HEY CHRISTMAS TREE loop
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE mod3
YOU SET US UP 1
HEY CHRISTMAS TREE result3
YOU SET US UP @I LIED
HEY CHRISTMAS TREE mod5
YOU SET US UP 1
HEY CHRISTMAS TREE result5
YOU SET US UP @I LIED
HEY CHRISTMAS TREE mod15
YOU SET US UP 1
HEY CHRISTMAS TREE result15
YOU SET US UP @I LIED
STICK AROUND loop
GET TO THE CHOPPER mod3
HERE IS MY INVITATION index
I LET HIM GO 3
ENOUGH TALK
GET TO THE CHOPPER result3
HERE IS MY INVITATION mod3
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK
GET TO THE CHOPPER mod5
HERE IS MY INVITATION index
I LET HIM GO 5
ENOUGH TALK
GET TO THE CHOPPER result5
HERE IS MY INVITATION mod5
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK
GET TO THE CHOPPER mod15
HERE IS MY INVITATION index
I LET HIM GO 15
ENOUGH TALK
GET TO THE CHOPPER result15
HERE IS MY INVITATION mod15
YOU ARE NOT YOU YOU ARE ME 0
ENOUGH TALK
BECAUSE I'M GOING TO SAY PLEASE result15
TALK TO THE HAND "FizzBuzz"
BULLSHIT
BECAUSE I'M GOING TO SAY PLEASE result3
TALK TO THE HAND "Fizz"
BULLSHIT
BECAUSE I'M GOING TO SAY PLEASE result5
TALK TO THE HAND "Buzz"
BULLSHIT
TALK TO THE HAND index
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE NO RESPECT FOR LOGIC
GET TO THE CHOPPER loop
HERE IS MY INVITATION limit
LET OFF SOME STEAM BENNET index
ENOUGH TALK
GET TO THE CHOPPER index
HERE IS MY INVITATION index
GET UP 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED
================================================
FILE: assembly.asm
================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Runs with nasm-2.11.05 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Courtesy - google and my engineering lab work ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; https://github.com/sunnypatel165/BELabCodes/tree/master/Microprocessors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Thanks! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .data
fizz dw "Fizz", 0Ah, 0Dh ;Define Fizz
buzz dw "Buzz", 0Ah, 0Dh ;Define Buzz
fizzbuzz dw "FizzBuzz", 0Ah, 0Dh ;Define FizzBuzz
newLine dw 0Ah, 0Dh ;Define \n
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;TEXT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .text
global _start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;INIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_start:
mov ecx, 1 ;counter=1
loop_main:
push ecx ;counter
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;LOGIC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
xor dx, dx ;reset
mov ax, cx
mov bx, 15
div bx
cmp dx, 0
jz divisible_by_both ;if divisible by both 3 and 5
xor dx, dx ;reset
mov ax, cx
mov bx, 3
div bx
cmp dx, 0
jz divisible_by_three ;if divisible by 3
xor dx, dx ;reset
mov ax, cx
mov bx, 5
div bx
cmp dx, 0
jz divisible_by_five ;if divisible by 5
mov eax, ecx ;eax = number to be printed
call print_num
jmp resume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;FIZZBUZZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
divisible_by_both:
mov eax, 4 ;System Call
mov ebx, 1
mov ecx, fizzbuzz
mov edx, 10
int 0x80
jmp resume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;FIZZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
divisible_by_three:
mov eax, 4 ;System Call
mov ebx, 1
mov ecx, fizz
mov edx, 6
int 0x80
jmp resume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUZZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
divisible_by_five:
mov eax, 4 ;System Call
mov ebx, 1
mov ecx, buzz
mov edx, 6
int 0x80
jmp resume
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UTILS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
resume:
pop ecx ;Counter
cmp ecx, 100
jz exit ;loop end
inc ecx ;counter++
jmp loop_main
exit:
mov eax, 1
mov ebx, 0 ;exit(0)
int 0x80
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print_num:
push esi ;save counter
mov esi, 0 ;counter = 0
loop_div: ;loop
mov edx, 0
mov ebx, 10 ;edx = mod 10
div ebx ;eax = dividide by 10
add edx, 48
push edx
inc esi ;counter++
cmp eax, 0
je print_chars ;done loop
jmp loop_div
print_chars:
cmp esi, 0
je done
dec esi ;counter--
mov eax, 4 ;System Call
mov ebx, 1
mov edx, 1
mov ecx, esp
int 0x80
add esp, 4
jmp print_chars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;PRINT\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
done:
mov eax, 4 ;System Call
mov ebx, 1
mov ecx, newLine
mov edx, 1
int 0x80
pop esi ;Counter
ret
================================================
FILE: awk.awk
================================================
# run with `awk -f awk.awk`
BEGIN{
for (i = 1; i <= 100; i++) {
if (i % 15 == 0) print("FizzBuzz")
else if (i % 5 == 0) print("Buzz")
else if (i % 3 == 0) print("Fizz")
else print(i)
}
exit(1)
}
================================================
FILE: b.b
================================================
fizzbuzz(n) {
extrn putchar;
if (n % 3 == 0) putchar('Fizz');
if (n % 5 == 0) putchar('Buzz');
if ((n % 3) && (n % 5)) putchar(n + '0');
putchar('*n');
}
main( ) {
extern fizzbuzz;
auto i;
i = 1;
while (i <= 100) fizzbuzz(i++);
}
================================================
FILE: batch.bat
================================================
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,100) do (
set /a mod3=%%i %% 3
set /a mod5=%%i %% 5
set print=
if !mod3!==0 set print=!print!Fizz
if !mod5!==0 set print=!print!Buzz
if "!print!"=="" set print=%%i
echo !print!
)
================================================
FILE: batsh.batsh
================================================
function fizzbuzz(i) {
if (i % 15 == 0) {
println("FizzBuzz");
} else if (i % 3 == 0) {
println("Fizz");
} else if (i % 5 == 0) {
println("Buzz");
} else {
println(i);
}
}
i = 1;
while (i < 101) {
fizzbuzz(i);
i = i + 1;
}
================================================
FILE: bc.bc
================================================
/* Works with GNU bc */
i = 1
while (i <= 100) {
if (i % 3 == 0) {
if (i % 5 == 0) print "FizzBuzz\n"
if (i % 5 != 0) print "Fizz\n"
}
if (i % 3 != 0) {
if (i % 5 == 0) print "Buzz\n"
if (i % 5 != 0) print i, "\n"
}
i = i + 1
}
quit
================================================
FILE: beta.bet
================================================
ORIGIN '~beta/basiclib/betaenv';
-- program: Descriptor --
(#
i: @integer;
fizzbuzz:
(#
number: @integer;
fizzy: (# n: @integer enter n exit n mod 3 = 0 #);
buzzy: (# n: @integer enter n exit n mod 5 = 0 #)
enter number
do
(if number->fizzy // true then
(if number->buzzy // true then
'FizzBuzz'->putText
else
'Fizz'->putText
if)
else
(if number->buzzy // true then 'Buzz'->putText else number->putInt if)
if);
newline
#)
do (for i: 100 repeat i->fizzbuzz for)
#)
================================================
FILE: brainfuck.bf
================================================
Code from https://github.com/Zomis/Brainduck/blob/master/src/main/resources/fizzbuzz.bf
TAPE MEANINGS
255 Start
254 A Fizz or Buzz text to print
253 End of Fizzes and Buzzes
252 Currently processed FizzBuzz calculation
TAPE OVERVIEW
Remaining Iterations
10 for Line Break
255 Start Marker
Counter
Boolean 1 or 0 for whether or not a fizzbuzz matches current counter
Some empty space for converting counter to string
Any Number of Sequences of the following
254 Indicator for FizzBuzz sequence
Counter
Countdown until next text output
Text any number of characters
Zero
Zero
254 and 253 marker to indicate the end of sequences
++++++++++[>++++++++++<-]> Initialize 100 (number of times to perform FizzBuzz)
$ lastLoop 'initialize100'
$ assert value == 100
>++++++++++ Line break
>- Start marker
>>>>> >>>>> > Empty space for counter to string conversion
SETUP Create the Fizz and Buzz sequences on the tape
without having to write plus more than 65 times for every character
Fizz
--> Create indicator
>+++++ +++++ [-
$ loop 'setupFizz'
>+++++ ++
>+++++ +++++
>+++++ +++++ ++
>+++++ +++++ ++
<<<<]
+++ Set modulo value to 3
>
>+++++
>++
>++
>>
Buzz = 66 117 122 122
-->> Create indicator
+++++ +++++ [-
$ loop 'setupBuzz'
> +++++ ++ 10 * 7 = 70
> +++++ +++++ ++ 10 * 12 = 120
> +++++ +++++ ++
> +++++ +++++ ++
<<<<]
+++++ Set modulo value to 5
>---- 70 minus 4 = 66
>--- 120 minus 3 = 117
>++ 120 plus 2 = 122
>++
>>
-->--- Mark the ending with 254 and 253
END OF SETUP
ALGORITHM START
$ nextLoop 'gotoStart'
+[-<+]- Go backwards to the 255 mark
<< Go to the countdown
[
$ loop 'main'
->> Decrease countdown
>+> Increase counter
$ nextLoop 'find254'
++[-->++]--> Find next 254 and go one step beyond it
Loop through all 254s
+++[--- Make sure that we are not at 253 (end)
$ loop 'notEnd'
<-- Go to 254 marker and change to 252 to indicate that we are processing it
>+ Increase fizzbuzz counter
>- Decrease fizzbuzz countdown
If current marker is NOT zero
$ nextLoop 'notZero'
[
<<++ Go left to value 252 and change to 254
$ nextLoop 'skipText'
[>] Go to a zero to avoid repeat in case there is a 254 value in the string
$ nextLoop 'next254'
++[-->++]-- < Find NEXT 254 marker and stop right before it
]
>++
Check if we are positioned on a 254 already then if skip this
$ nextLoop 'matchFound'
[--
We have a match so find start position and mark match
$ nextLoop 'find255'
+[-<+]- >> Find 255 marker and go to the boolean
$ nextLoop 'setBoolean'
[-]+ Set boolean to 1 whatever the previous value is
$ nextLoop 'find252'
++++[---->++++]-- Find value 252 and change to 254
$ nextLoop 'resetCountdown'
>[->+<] Reset the current FizzBuzz countdown
$ nextLoop 'printText'
>>[.>] Print the text
$ nextLoop 'next254'
++[-->++] Go to next 254 change to 256 to break loop
]
-->
+++ Detect if we are at the 253 end
]
---
ALL FIZZBUZZES PROCESSED
Use the boolean to check whether or not to print the number
$ nextLoop 'search255_afterFizzBuzzes'
+[-<+]- Go back to the 255 marker
>> Go to boolean
-[+ If boolean is zero then print the number
$ nextLoops 'printNumber'
Code taken from StackOverflow below for printing a number
>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-
<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++
<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]
End of StackOverflow code
cursor is now located on the boolean
]
Boolean is now zero so just print the new line
<<<. Print new line
< Go to the countdown to find out if we should go another round
]
================================================
FILE: buzzfizz.buzzfizz
================================================
# Based on: https://esolangs.org/wiki/BuzzFizz#FizzBuzz
if 100\$a: # do nothing
else: # do nothing
# $a is the counter.
$a++
# if-if-else construct checking whether 3 and 5 divide
# into the number.
if 3\$a: print "Fizz"
if 5\$a: print "Buzz"
else: print $a
# Write the trailing newline.
print "\n"
# Loop if there is more to write.
if 100\$a: # do nothing
else: loop
================================================
FILE: c++.cpp
================================================
#include <iostream>
void fizzbuzz(int);
int main(void)
{
for (int i = 0; i <= 100; i++) {
fizzbuzz(i);
}
}
void fizzbuzz(int num)
{
if (num % 15 == 0) {
std::cout << "FizzBuzz" << std::endl;
} else if (num % 5 == 0) {
std::cout << "Buzz" << std::endl;
} else if (num % 3 == 0) {
std::cout << "Fizz" << std::endl;
} else {
std::cout << num << std::endl;
}
}
================================================
FILE: c.c
================================================
#include <stdio.h>
void fizzbuzz(int);
int main(void)
{
for (int i = 1; i <= 100; i++) {
fizzbuzz(i);
}
return 0;
}
void fizzbuzz(int num)
{
int printed = 0;
if (num % 3 == 0) {
printf("Fizz");
printed = 1;
}
if (num % 5 == 0) {
printf("Buzz");
printed = 1;
}
if (printed) {
printf("\n");
} else {
printf("%d\n", num);
}
}
================================================
FILE: cesil.csl
================================================
LOAD 0
( PROCESS NEXT NUMBER
MAIN ADD 1
STORE NUMBER
LOAD 1
STORE NOTFB
( FIZZ CHECK
CHKF LOAD NUMBER
DIVIDE 3
MULTIPLY 3
SUBTRACT NUMBER
JIZERO PRTF
JUMP CHKB
PRTF PRINT "Fizz"
LOAD 0
STORE NOTFB
( BUZZ CHECK
CHKB LOAD NUMBER
DIVIDE 5
MULTIPLY 5
SUBTRACT NUMBER
JIZERO PRTB
JUMP PRTN
PRTB PRINT "Buzz"
LOAD 0
STORE NOTFB
( OUTPUT NUMBER IF NOT FIZZ OR BUZZ
PRTN LOAD NOTFB
JIZERO NEXT
LOAD NUMBER
OUT
( CURRENT NUMBER CHECK
NEXT LOAD NUMBER
SUBTRACT 100
JIZERO END
LINE
LOAD NUMBER
JUMP MAIN
END HALT
%
*
================================================
FILE: chapel.chpl
================================================
proc fizzBuzz(i:int):string {
if (i % 15 == 0) {
return 'FizzBuzz';
} else if (i % 3 == 0) {
return 'Fizz';
} else if (i % 5 == 0) {
return 'Buzz';
} else {
return i: string;
}
}
for i in 1..100 do writeln(fizzBuzz(i));
================================================
FILE: clisp.lisp
================================================
(defun fizzbuzz (n)
(cond ((= (mod n 15) 0) "FizzBuzz")
((= (mod n 3) 0) "Fizz")
((= (mod n 5) 0) "Buzz")
(t (write-to-string n))))
(loop for i from 1 to 100
do (write-line (fizzbuzz i)))
================================================
FILE: clojure.clj
================================================
(defn- fizz-buzz [n]
(cond
(zero? (rem n 15)) "FizzBuzz"
(zero? (rem n 3)) "Fizz"
(zero? (rem n 5)) "Buzz"
:else (Integer/toString n)))
(defn- fizz-buzz-gen []
(->> (range 1 Integer/MAX_VALUE)
(map fizz-buzz)))
(defn- main []
(doseq [i (vec (take 100 (fizz-buzz-gen)))]
(println i)))
================================================
FILE: cobol.cbl
================================================
IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZ-BUZZ.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CT PIC 999 VALUE 1.
01 FZ PIC 999 VALUE 1.
01 BZ PIC 999 VALUE 1.
01 RESULT-STRING PIC x(3).
01 SPACE-COUNT PIC 99 VALUE ZERO.
PROCEDURE DIVISION.
FIZZ-BUZZ-MAIN SECTION.
PERFORM 100 TIMES
IF FZ = 3
THEN IF BZ = 5
THEN DISPLAY "FizzBuzz"
COMPUTE BZ = 0
ELSE DISPLAY "Fizz"
END-IF
COMPUTE FZ = 0
ELSE IF BZ = 5
THEN DISPLAY "Buzz"
COMPUTE BZ = 0
ELSE
MOVE 0 TO SPACE-COUNT
INSPECT CT TALLYING SPACE-COUNT
FOR LEADING ZEROES
MOVE CT
(SPACE-COUNT + 1 :
LENGTH OF CT - SPACE-COUNT)
TO RESULT-STRING
DISPLAY RESULT-STRING
END-IF
END-IF
ADD 1 TO CT
ADD 1 TO FZ
ADD 1 TO BZ
END-PERFORM
STOP RUN.
================================================
FILE: coffeescript.coffee
================================================
fizz_buzz = (i) ->
if i % 15 == 0
return 'FizzBuzz'
else if i % 5 == 0
return 'Buzz'
else if i % 3 == 0
return 'Fizz'
else
return i
console.log fizz_buzz num for num in [1..100]
================================================
FILE: commodore_basic.bas
================================================
100 FOR X = 1 TO 100
110 FLAG=1
120 IF NOT (X-INT(X/3)*3)=0 THEN 150
130 FLAG=0
140 PRINT "FIZZ";
150 IF NOT (X-INT(X/5)*5)=0 THEN 180
160 FLAG=0
170 PRINT "BUZZ";
180 IF FLAG=1 THEN PRINT X;
190 PRINT
200 NEXT X
RUN
================================================
FILE: crystal.cr
================================================
def fizz_buzz(num : Int)
if num % 15 == 0
puts "FizzBuzz"
elsif num % 3 == 0
puts "Fizz"
elsif num % 5 == 0
puts "Buzz"
else
puts num
end
end
(1..100).each do |x|
fizz_buzz(x)
end
================================================
FILE: csharp.cs
================================================
using System;
namespace FizzBuzz
{
public class Program
{
public static void FizzBuzz(int number)
{
if (number%3 == 0 && number%5 == 0)
{
Console.WriteLine("FizzBuzz");
}
else if (number%3 == 0)
{
Console.WriteLine("Fizz");
}
else if (number%5 == 0)
{
Console.WriteLine("Buzz");
}
else
{
Console.WriteLine(number);
}
}
private static void Main(string[] args)
{
for (int i = 0; i <= 100; i++)
{
FizzBuzz(i);
}
}
}
}
================================================
FILE: csharp10.cs
================================================
foreach (var i in Enumerable.Range(1, 100))
Console.WriteLine(FizzBuzz(i));
static string FizzBuzz(int number) =>
(number % 3, number % 5) switch
{
(0, 0) => "FizzBuzz",
(0, _) => "Fizz",
(_, 0) => "Buzz",
_ => number.ToString(),
};
================================================
FILE: cuneiform.cfl
================================================
%%====================================================================
%% Functions
%%====================================================================
def range( first : Str, last : Str ) ->
<number_lst : [Str]>
in Python *{
number_lst = [str( x ) for x in range( int( first ), int( last )+1 )]
}*
def is_multiple( number : Str, divisor : Str ) ->
<is_multiple : Bool>
in Python *{
is_multiple = int( number ) % int( divisor ) == 0
}*
%%====================================================================
%% Constants
%%====================================================================
let last : Str = 100;
%%====================================================================
%% Workflow
%%====================================================================
let <number_lst = number_lst : [Str]> =
range( first = 1,
last = last );
let fizzbuzz_lst : [Str] =
for x <- number_lst do
let <is_multiple = f : Bool> =
is_multiple( number = x,
divisor = 3 );
let <is_multiple = b : Bool> =
is_multiple( number = x,
divisor = 5 );
if ( f and b ) then "FizzBuzz"
else
if f then "Fizz"
else
if b then "Buzz"
else
x
end
end
end
: Str
end;
%%====================================================================
%% Query
%%====================================================================
fizzbuzz_lst;
================================================
FILE: d.d
================================================
import std.stdio;
int main() {
foreach(i; 1..101) {
fizzbuzz(i);
} return 0;
}
void fizzbuzz(int i) {
if (i % 15 == 0)
writeln("FizzBuzz");
else if (i % 3 == 0)
writeln("Fizz");
else if (i % 5 == 0)
writeln("Buzz");
else
writeln(i);
}
================================================
FILE: dafny.dfy
================================================
method FizzBuzz(i: nat)
{
if i % 15 == 0 {
print "FizzBuzz\n";
} else if i % 3 == 0 {
print "Fizz\n";
} else if i % 5 == 0 {
print "Buzz\n";
} else {
print i, "\n";
}
}
method Main() {
var i := 0;
while i < 100
invariant 0 <= i <= 100;
decreases 100 - i;
{
i := i + 1;
FizzBuzz(i);
}
}
================================================
FILE: dart.dart
================================================
void fizzBuzz(int foo) {
if (foo % 15 == 0) {
print("FizzBuzz");
} else if (foo % 5 == 0) {
print("Buzz");
} else if (foo % 3 == 0) {
print("Fizz");
} else {
print(foo);
}
}
void main() {
for (var i = 1; i <= 100; i++) {
fizzBuzz(i);
}
}
================================================
FILE: dc.dc
================================================
# MACROS
# The following macro prints "Fizz" (without a newline) and writes 1 to register
# X. We store the macro in register A.
[[Fizz] P 1 sX] sA
# This macro prints "Buzz" (without a newline) and writes 1 to register X. We
# store it in register B.
[[Buzz] P 1 sX] sB
# This macro prints the number on the top of the stack with a newline. We store
# it in register C.
[p] sC
# This macro prints a newline. We store it in register D.
[[
] P] sD
# MAIN PROGRAM
# We push the current position to the stack. It doesn't have a name, but in the
# comments we'll call it i.
1
# Here's the main run loop, which will be written to register F:
[
# Register X tells us if we've printed something for the current iteration. We
# haven't yet, so we write 0 to register X.
0 sX
# Calculate i % 3. If it's 0, invoke the macro in register A.
d 3 % 0 =A
# Calculate i % 5. If it's 0, invoke the macro in register B.
d 5 % 0 =B
# If one or both of the macros was invoked, then register X is now 1. If it's
# still 0, then nothing has been printed and we need to print i.
# Read register X. If it's 0, invoke register C. If it's 1, invoke register D.
lX 0 =C
lX 1 =D
# Increment i by 1.
1 +
# If i != 101, invoke the macro in register E (which is this one).
d 101 >E
] d sE x
================================================
FILE: delphi.delphi
================================================
program FizzBuzz;
{$APPTYPE CONSOLE}
uses SysUtils;
var
i: Integer;
begin
for i := 1 to 100 do
begin
if i mod 15 = 0 then
Writeln('FizzBuzz')
else if i mod 3 = 0 then
Writeln('Fizz')
else if i mod 5 = 0 then
Writeln('Buzz')
else
Writeln(i);
end;
end.
================================================
FILE: eiffel.e
================================================
class
APPLICATION
create
make
feature {NONE}
make
do
across
1 |..| 100 as i
loop
fizzbuzz(i.item)
end
end
fizzbuzz(n: INTEGER)
require
n >= 0
do
if n \\ 15 = 0 then io.put_string("FIZZBUZZ")
elseif n \\ 3 = 0 then io.put_string("FIZZ")
elseif n \\ 5 = 0 then io.put_string("BUZZ")
else io.put_integer(n)
end
io.put_new_line
end
end
================================================
FILE: elisp.el
================================================
:;exec emacs -Q --script "$0" "$@"
(defun fizzbuzz (n)
(append (if (> n 1) (fizzbuzz (1- n)))
(list (pcase `(,(% n 3) ,(% n 5))
(`(0 0) "FizzBuzz")
(`(0 ,_) "Fizz")
(`(,_ 0) "Buzz")
(`(,_ ,_) (number-to-string n))))))
(princ (mapconcat 'identity (mapcar (lambda (x) (concat x "\n")) (fizzbuzz 100)) ""))
================================================
FILE: elixir.exs
================================================
fizzbuzz = fn
n when rem(n, 15) == 0 -> "FizzBuzz"
n when rem(n, 3) == 0 -> "Fizz"
n when rem(n, 5) == 0 -> "Buzz"
n -> to_string n
end
1..100 |> Enum.map(fizzbuzz) |> Enum.each(&IO.puts/1)
================================================
FILE: enkelt.e
================================================
def fizz_buzz($num) {
om($num % 15 == 0) {
skriv("FizzBuzz")
}
anom($num % 5 == 0) {
skriv("Buzz")
}
anom($num % 3 == 0) {
skriv("Fizz")
}
annars {
skriv($num)
}
}
för($i; inom området(1, 101)) {
fizz_buzz($i)
}
================================================
FILE: escript.erl
================================================
#!/usr/bin/env escript
main(_) ->
fizz_buzz(1, 101).
fizz_buzz(Max, Max) ->
ok;
fizz_buzz(N, Max) when N rem 15 == 0 ->
io:format("FizzBuzz~n"),
fizz_buzz(N+1, Max);
fizz_buzz(N, Max) when N rem 3 == 0 ->
io:format("Fizz~n"),
fizz_buzz(N+1, Max);
fizz_buzz(N, Max) when N rem 5 == 0->
io:format("Buzz~n"),
fizz_buzz(N+1, Max);
fizz_buzz(N, Max) ->
io:format("~p~n", [N]),
fizz_buzz(N+1, Max).
================================================
FILE: forth.fth
================================================
#! /usr/bin/env gforth
: FIZZBUZZ ( -- )
1
101 1 ?DO
DUP 15 MOD 0= IF
." FizzBuzz" CR
ELSE
DUP 3 MOD 0= IF
." Fizz" CR
ELSE
DUP 5 MOD 0= IF
." Buzz" CR
ELSE
DUP 1 .r CR
THEN
THEN
THEN
1+
LOOP
DROP
;
FIZZBUZZ
BYE
================================================
FILE: fortran.f90
================================================
PROGRAM fizzbuzz
IMPLICIT NONE
INTEGER :: counter
DO counter=0,100
IF (MOD(counter,15) == 0) THEN
WRITE (*,'(A8)') "FizzBuzz"
ELSE IF (MOD(counter,5) == 0) THEN
WRITE (*,'(A4)') "Buzz"
ELSE IF (MOD(counter,3) == 0) THEN
WRITE (*,'(A4)') "Fizz"
ELSE
WRITE (*,'(I2)') counter
END IF
END DO
END PROGRAM fizzbuzz
================================================
FILE: fsharp.fs
================================================
let fizzbuzz (n : int) : string =
match n % 3, n % 5 with
| 0, 0 -> "FizzBuzz"
| 0, _ -> "Fizz"
| _, 0 -> "Buzz"
| _, _ -> string n
for n in 1 .. 100 do
printfn "%s" (fizzbuzz n)
================================================
FILE: gamemakerlanguage.gml
================================================
for (var i = 1; i <= 100; i++)
{
if (i % 15 == 0) {
draw_text(x,i*12.2,"FizzBuzz");
} else if (i % 5 == 0) {
draw_text(x,i*12.2,"Buzz");
} else if (i % 3 == 0) {
draw_text(x,i*12.2,"Fizz");
} else {
draw_text(x,i*12.2,i);
}
}
================================================
FILE: gdscript.gd
================================================
extends Node
func fizz_buzz(num):
if(num % 15 == 0):
print("FizzBuzz")
elif(num % 5 == 0):
print("Buzz")
elif(num % 3 == 0):
print("Fizz")
else:
print(num)
func _ready():
for i in range(1, 101):
fizz_buzz(i)
================================================
FILE: go.go
================================================
// Author: Jinwei Zhao
// Date: 2015.4.9
package main
import (
"fmt"
)
func fizzbuzz(num int) {
if num%3 == 0 && num%5 == 0 {
fmt.Println("FizzBuzz")
} else if num%5 == 0 {
fmt.Println("Buzz")
} else if num%3 == 0 {
fmt.Println("Fizz")
} else {
fmt.Println(num)
}
}
func main() {
for i := 1; i < 100; i++ {
fizzbuzz(i)
}
}
================================================
FILE: groovy.groovy
================================================
def fizzbuzz = {
if(it % 15 == 0){
"FizzBuzz"
}else if(it % 3 == 0){
"Fizz"
}else if(it % 5 == 0){
"Buzz"
}else{
it
}
}
(1..100).each {
println fizzbuzz(it)
}
================================================
FILE: haskell.hs
================================================
module Main where
fizzbuzz :: Int -> String
fizzbuzz x
| x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 3 == 0 = "Fizz"
| x `mod` 5 == 0 = "Buzz"
| otherwise = show x
main = mapM (putStrLn . fizzbuzz) [1..100]
================================================
FILE: holyc.HC
================================================
/*
* To use, you need TempleOS
* In TempleOS, include the file
* -> #include "holyc.HC"
* and from the shell, call it
* -> Fizzbuzz(1, 100);
*/
U0 Fizzbuzz(I64 Start, I64 End) {
I64 i = Start;
while (i <= End) {
if (i % 3 && i % 5) {
"%d", i;
}
if (!(i % 3)) {
"Fizz";
}
if (!(i % 5)) {
"Buzz";
}
'\n';
i++;
}
}
================================================
FILE: hoon.hoon
================================================
:- %say
|= [^ ~ ~]
:- %noun
%+ turn (gulf [1 101])
|= a=@
=+ q=[=(0 (mod a 3)) =(0 (mod a 5))]
?+ q <a>
[& &] "FizzBuzz"
[& |] "Fizz"
[| &] "Buzz"
==
================================================
FILE: io.io
================================================
#io language http://iolanguage.org/
FizzBuzz := method(a,
if (a % 15 == 0,
writeln("FizzBuzz"),
if (a % 3 == 0,
writeln("Fizz"),
if (a % 5 == 0,
writeln("Buzz"),
writeln(a)
)
)
)
)
for (x, 1, 100, 1,
FizzBuzz(x)
)
================================================
FILE: j.j
================================================
(":[^:(''-:])(('Fizz'#~0=3&|),'Buzz'#~0=5&|))"0>:i.100
================================================
FILE: java.java
================================================
public class java
{
public static void main(String[] args)
{
for (int i=1; i<=100; i++) {
fizzBuzz(i);
}
}
public static void fizzBuzz(int num)
{
if (num % 15 == 0) {
System.out.println("FizzBuzz");
} else if (num % 5 == 0) {
System.out.println("Buzz");
} else if (num % 3 == 0) {
System.out.println("Fizz");
} else {
System.out.println(num);
}
}
}
================================================
FILE: javascript.js
================================================
function fizz_buzz(num) {
if (num % 15 === 0) {
console.log("FizzBuzz");
} else if (num % 5 === 0) {
console.log("Buzz");
} else if (num % 3 === 0) {
console.log("Fizz");
} else {
console.log(num);
}
}
for (var i = 1; i <= 100; i++) {
fizz_buzz(i);
}
================================================
FILE: julia.jl
================================================
function FizzBuzz(num)
if num % 15 == 0
println("FizzBuzz")
elseif num % 5 == 0
println("Buzz")
elseif num % 3 == 0
println("Fizz")
else
println(num)
end
end
for i = 1:100
FizzBuzz(i)
end
================================================
FILE: kotlin.kt
================================================
fun main(args: Array<String>) {
(1..100).forEach {
println(when (0) {
it % 3 -> "Fizz${if (it % 5 == 0) "Buzz" else ""}"
it % 5 -> "Buzz"
else -> it
})
}
}
================================================
FILE: labyrinth.lab
================================================
)::}_101-@ Increment the counter, leave a copy on aux, check if we're below 101, otherwise terminate.
" { This leaves a negative number on main.
" :
" }_5%122:_117_66 If 5 divides the counter push "Buzz" in reverse order.
" " "
" """"";{"""""
" :
" }_3%122:_105_70 If 3 divides the counter push "Fizz" in reverse order.
" " "
" """"""1_""""
" ;
""""""""""""""""""""""\!{;``{ If the negative number was still on top, just print the counter.
; ; Otherwise, we found at least one of the two divisors and print
\"""""""""""""""""""""""""""" everything until we hit the negative number (which we discard).
."
================================================
FILE: lobster.lobster
================================================
// FizzBuzz in [lobster](https://www.strlen.com/lobster/)
def fizz(x):
if x % 15 == 0:
print "FizzBuzz"
elif x % 5 == 0:
print "Buzz"
elif x % 3 == 0:
print "Fizz"
else:
print x
def buzz():
for (100) i:
fizz(i+1)
buzz()
================================================
FILE: lolcode.lol
================================================
HAI 1.2
IM IN YR FIZZBUZZLOOP UPPIN YR LOOPVAR TIL BOTH SAEM LOOPVAR AN 100
I HAS A FIZZBUZZVAR ITZ SUM OF LOOPVAR AN 1
BOTH SAEM MOD OF FIZZBUZZVAR AN 15 AN 0, O RLY?
YA RLY
VISIBLE "FizzBuzz"
NO WAI
BOTH SAEM MOD OF FIZZBUZZVAR AN 5 AN 0, O RLY?
YA RLY
VISIBLE "Buzz"
NO WAI
BOTH SAEM MOD OF FIZZBUZZVAR AN 3 AN 0, O RLY?
YA RLY
VISIBLE "Fizz"
NO WAI
VISIBLE FIZZBUZZVAR
OIC
OIC
OIC
IM OUTTA YR FIZZBUZZLOOP
KTHXBYE
================================================
FILE: lolpython.lol
================================================
SO IM LIKE MODDIN WIT X AND Y OK?
I CAN HAS X SMASHES NICELY INTO Y
U TAKE X TAKE AWAY Y OF THOSE I
SO IM LIKE FIZZBUZZIN WIT N OK?
IZ MODDIN WIT N AND FIV OF THOSE THR33 OK KINDA LIKE EASTERBUNNY?
U TAKE "FizzBuzz"
OR IZ MODDIN WIT N AND FIV OK KINDA LIKE EASTERBUNNY?
U TAKE "Buzz"
OR IZ MODDIN WIT N AND THR33 OK KINDA LIKE EASTERBUNNY?
U TAKE "Fizz"
NOPE?
U TAKE N
GIMME EACH N IN UR NUMBRZ CHEEZBURGER AND 101 OK?
VISIBLE FIZZBUZZIN WIT N!
================================================
FILE: lua.lua
================================================
function fizz_buzz (n)
if n % 3 == 0 then
if n % 5 == 0 then
io.write('FizzBuzz')
else
io.write('Fizz')
end
elseif n % 5 == 0 then
io.write('Buzz')
else
io.write(n)
end
io.write('\n')
end
for i = 1, 100 do
fizz_buzz(i)
end
================================================
FILE: matlab.m
================================================
for inum = 1:100
fizzbuzz = '';
if mod(inum,3) == 0
fizzbuzz = [fizzbuzz 'Fizz'];
end
if mod(inum,5) == 0
fizzbuzz = [fizzbuzz 'Buzz'];
end
if isempty(fizzbuzz)
disp(num2str(inum))
else
disp(fizzbuzz)
end
end
================================================
FILE: mercury.m
================================================
:- module mercury. %% Mercury requires that the module name is the same as the
%% file name.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int, string, bool.
:- func fizz(int) = bool.
:- func buzz(int) = bool.
:- func fizzbuzz(int, bool, bool) = string.
fizz(N) = (if N mod 3 = 0 then yes else no).
buzz(N) = (if N mod 5 = 0 then yes else no).
fizzbuzz(_, yes, yes) = "FizzBuzz".
fizzbuzz(_, yes, no) = "Fizz".
fizzbuzz(_, no, yes) = "Buzz".
fizzbuzz(N, no, no) = from_int(N).
:- pred print_fizzbuzz(int::in, int::in, io::di, io::uo) is det.
print_fizzbuzz(N, Upper, !IO) :-
io.write_string(fizzbuzz(N, fizz(N), buzz(N)), !IO),
io.nl(!IO),
(if N < Upper
then print_fizzbuzz(N + 1, Upper, !IO)
else !:IO = !.IO). %% Do not change the IO state. This is a no-op,
%% but since `if` clauses must have an `else`, we
%% need to return something.
main(!IO) :- print_fizzbuzz(1, 100, !IO).
================================================
FILE: mysql.sql
================================================
select
case
when n %15 = 0 then 'FizzBuzz'
when n %3 = 0 then 'Fizz'
when n %5 = 0 then 'Buzz'
else n end fizzbuzz
from (
select @no := @no+1 n
from (select @no := 0) t0
, (select 1 union all select 2 union all select 3 union all select 4) t1
, (select 1 union all select 2 union all select 3 union all select 4) t2
, (select 1 union all select 2 union all select 3 union all select 4) t3
, (select 1 union all select 2 union all select 3 union all select 4) t4
limit 100
) tx
================================================
FILE: nim.nim
================================================
func fizzbuzz(n: int): string =
if n mod 15 == 0:
result = "FizzBuzz"
elif n mod 3 == 0:
result = "Fizz"
elif n mod 5 == 0:
result = "Buzz"
else:
result = $n
for i in 0..100:
echo fizzbuzz(i)
================================================
FILE: objc.m
================================================
/*
Build on OS X:
clang -framework Foundation -fobjc-arc objc.m -o objc
Build on Linux with GNUstep:
clang `gnustep-config --objc-flags` `gnustep-config --base-libs` -fobjc-nonfragile-abi -fobjc-arc objc.m -o objc
*/
#import <Foundation/Foundation.h>
void FizzBuzz(int num) {
if (num % 15 == 0) {
NSLog(@"FizzBuzz");
}
else if (num % 5 == 0) {
NSLog(@"Buzz");
}
else if (num % 3 == 5) {
NSLog(@"Fizz");
}
else {
NSLog(@"%d", num);
}
}
int main(void)
{
for (int i = 1; i <= 100; i++) {
FizzBuzz(i);
}
}
================================================
FILE: ocaml.ml
================================================
let fizz_buzz n =
if n mod 5 == 0 && n mod 3 == 0 then print_string "FizzBuzz\n"
else if n mod 5 == 0 then print_string "Buzz\n"
else if n mod 3 == 0 then print_string "Fizz\n"
else print_string ((string_of_int n) ^ "\n")
;;
for i = 1 to 100
do
fizz_buzz i
done
;;
================================================
FILE: octave.m
================================================
% Running code - http://ideone.com/uGgJMt
% Must mention coursera ML course by Andrew NG, did it more than 3 years back, still was able to write this!
for number = 1:100
if ( mod(number,15) == 0 )
disp('FizzBuzz');
elseif ( mod(number, 3) == 0 )
disp('Fizz')
elseif ( mod(number, 5) == 0 )
disp('Buzz')
else
disp(num2str(number))
endif
endfor
================================================
FILE: pascal.p
================================================
program FizzBuzz(output);
var
i : integer;
begin
for i := 1 to 100 do
if i mod 15 = 0 then
writeln('FizzBuzz')
else if i mod 3 = 0 then
writeln('Fizz')
else if i mod 5 = 0 then
writeln('Buzz')
else
writeln(i)
end.
================================================
FILE: pawn.p
================================================
fizzBuzz(num) {
if (num % 3 == 0 && num % 5 == 0) {
print("FizzBuzz\n")
} else if (num % 3 == 0) {
print("Fizz\n")
} else if ( num % 5 == 0) {
print("Buzz\n")
} else {
printf("%d\n", num)
}
}
main() {
for(new i = 0;i <= 100;i++)
{
fizzBuzz(i)
}
return 1;
}
================================================
FILE: perl.pl
================================================
#!/usr/bin/env perl
for (my $i = 1; $i < 101; $i++) {
if ($i % 15 == 0) {
print "FizzBuzz\n";
} elsif ($i % 3 == 0) {
print "Fizz\n";
} elsif ($i % 5 == 0) {
print "Buzz\n";
} else {
print "$i\n";
}
}
================================================
FILE: perl6.pl
================================================
#!/usr/bin/env perl6
for 1 .. 100 {
if ($_ % 15 == 0) {
say "FizzBuzz";
} elsif ($_ % 3 == 0) {
say "Fizz";
} elsif ($_ % 5 == 0) {
say "Buzz";
} else {
say $_;
}
}
================================================
FILE: php.php
================================================
<?php
function fizzbuzz($num) {
if ($num % 15 == 0) {
print("FizzBuzz" . PHP_EOL);
} else if ($num % 5 == 0) {
print("Buzz" . PHP_EOL);
} else if ($num % 3 == 0) {
print("Fizz" . PHP_EOL);
} else {
print($num . PHP_EOL);
}
}
for ($i = 0; $i <=100; $i++)
{
fizzbuzz($i);
}
================================================
FILE: pinecone.pn
================================================
# FizzBuzz
# call the function defined below
fizzBuzz: 1, 100
# define the FizzBuzz function
fizzBuzz :: {start: Int, end: Int}: (
# loop i from start to end
i: in.start | i <= in.end | i: i+1 @ (
# use conditionals to print the right thing
i % 3 = 0 && i % 5 = 0 ?
print: "FizzBuzz"
|
i % 3 = 0 ?
print: "Fizz"
|
i % 5 = 0 ?
print: "Buzz"
|
print: i
)
)
================================================
FILE: pony.pony
================================================
use "collections"
actor Main
new create(env: Env) =>
for i in Range[I32](1, 100) do
env.out.print(fizzbuzz(i))
end
fun fizzbuzz(n: I32): String =>
if (n % 15) == 0 then
"FizzBuzz"
elseif (n % 5) == 0 then
"Buzz"
elseif (n % 3) == 0 then
"Fizz"
else
n.string()
end
================================================
FILE: postgresql.sql
================================================
--http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/11608
--Runs with postgresql 9.3
--This will not match with the expected output because of the column header called "FizzBuzzOrBoth" !
SELECT FizzBuzzOrBoth
FROM
(SELECT
CASE
WHEN i % 15 = 0 THEN 'FizzBuzz'
WHEN i % 5 = 0 THEN 'Buzz'
WHEN i % 3 = 0 THEN 'Fizz'
ELSE i::text
END AS FizzBuzzOrBoth
FROM generate_series(1,100) AS i)
AS FizzBuzzOrBothTable ;
================================================
FILE: potigol.poti
================================================
para i de 1 até 100 faça
se i mod 15 == 0
escreva "FizzBuzz"
senãose i mod 5 == 0
escreva "Buzz"
senãose i mod 3 == 0
escreva "Fizz"
senão
escreva i
fim
================================================
FILE: processing.pde
================================================
void setup() {
for (int i=1; i<=100; i++) {
if (i % 15 == 0) {
println("FizzBuzz");
} else if (i % 5 == 0) {
println("Buzz");
} else if (i % 3 == 0) {
println("Fizz");
} else {
println(i);
}
}
}
================================================
FILE: prolog.pl
================================================
% Clauses to print FizzBuzz for values 1 up to N
fizzBuzzToN(N) :- var(N),
writeln("Missing argument").
fizzBuzzToN(1) :- writeln(1).
fizzBuzzToN(N) :- N2 is (N - 1),
fizzBuzzToN(N2),
fizzBuzz(N).
% Clauses to print FizzBuzz for a specific N
fizzBuzz(N) :- var(N),
writeln("Missing argument").
fizzBuzz(N) :- 0 is (N mod 15),
writeln("FizzBuzz").
fizzBuzz(N) :- 0 is (N mod 5),
writeln("Buzz").
fizzBuzz(N) :- 0 is (N mod 3),
writeln("Fizz").
fizzBuzz(N) :- writeln(N).
% Print FizzBuzz for values 1 up to 100
?- fizzBuzzToN(100).
================================================
FILE: pyret.arr
================================================
fun multiple-of(n :: Number, m :: Number) -> Boolean:
doc: ```Consumes numbers `n` and `m` and produces true if `n` is a multiple of `m`, otherwise produces false.```
num-modulo(n, m) == 0
where:
# Tests for `multiple-of`
multiple-of(4, 2) is true
multiple-of(4, 3) is false
10 is%(multiple-of) 5
10 is-not%(multiple-of) 6
5 satisfies multiple-of(15, _)
5 violates multiple-of(16, _)
end
fun fizz-buzz(n):
ask:
| multiple-of(n, 15) then: print("FizzBuzz")
| multiple-of(n, 3) then: print("Fizz")
| multiple-of(n, 5) then: print("Buzz")
| otherwise: print(n)
end
end
for each(n from range(1, 101)):
fizz-buzz(n)
end
================================================
FILE: python.py
================================================
#!/usr/bin/env python
from __future__ import print_function
try:
range = xrange
except NameError: # Python2's xrange is already just range in Python3.
pass
def fizz_buzz(num):
if num % 15 == 0:
print("FizzBuzz")
elif num % 5 == 0:
print("Buzz")
elif num % 3 == 0:
print("Fizz")
else:
print(num)
for i in range(1, 101):
fizz_buzz(i)
================================================
FILE: python2.py
================================================
#!/usr/bin/env python2
def fizz_buzz(num):
if num % 15 == 0:
print "FizzBuzz"
elif num % 5 == 0:
print "Buzz"
elif num % 3 == 0:
print "Fizz"
else:
print num
for i in xrange(1, 101):
fizz_buzz(i)
================================================
FILE: python3.py
================================================
#!/usr/bin/env python3
def fizz_buzz(num):
if num % 15 == 0:
print("FizzBuzz")
elif num % 5 == 0:
print("Buzz")
elif num % 3 == 0:
print("Fizz")
else:
print(num)
for i in range(1, 101):
fizz_buzz(i)
================================================
FILE: r.R
================================================
fizz_buzz <- function(num_array=seq_len(100L)){
result_array <- Map(function(r,n){cat(paste0(ifelse(r=='',n,r),'\n'))},
r=paste0(ifelse(num_array%%3L,'','Fizz'),
ifelse(num_array%%5L,'','Buzz')),
n=num_array)
}
fizz_buzz()
================================================
FILE: racket.rkt
================================================
#lang racket
(define (fizzbuzz n)
(if (= 0 n)
#t
(begin (fizzbuzz (- n 1))
(if (= 0 (remainder n 15))
(printf "FizzBuzz")
(if (= 0 (remainder n 5))
(printf "Buzz")
(if (= 0 (remainder n 3))
(printf "Fizz")
(print n)
)))
(printf "\n")
)))
(fizzbuzz 100)
================================================
FILE: rockstar.rock
================================================
Midnight takes your heart and your soul
While your heart is as high as your soul
Put your heart without your soul into your heart
Give back your heart
Desire is a lovestruck ladykiller
My world is nothing
Fire is ice
Hate is water
Until my world is Desire,
Build my world up
If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing
Shout "FizzBuzz!"
Take it to the top
If Midnight taking my world, Fire is nothing
Shout "Fizz!"
Take it to the top
If Midnight taking my world, Hate is nothing
Say "Buzz!"
Take it to the top
Whisper my world
================================================
FILE: ruby.rb
================================================
#!/usr/bin/env ruby
def fizz_buzz(num)
result = ''
result += 'Fizz' if (num % 3).zero?
result += 'Buzz' if (num % 5).zero?
puts result.empty? ? num : result
end
(1..100).each { |x| fizz_buzz x }
================================================
FILE: rust.rs
================================================
fn fizzbuzz(i: u8) {
if i % 15 == 0 {
println!("FizzBuzz");
} else if i % 3 == 0 {
println!("Fizz");
} else if i % 5 == 0 {
println!("Buzz");
} else {
println!("{}", i.to_string());
}
}
fn main() {
for i in 1..101 {
fizzbuzz(i);
}
}
================================================
FILE: sassy-css.scss
================================================
// This output is not the traditional output
// expected for FizzBuzz but it does generate
// CSS classes for appending the correct
// FizzBuzz result to an HTML element
@for $i from 1 through 100 {
.fizzbuzz-#{$i}:after {
@if $i % 15 == 0 {
content: "FizzBuzz";
} @else if $i % 5 == 0 {
content: "Buzz";
} @else if $i % 3 == 0 {
content: "Fizz";
} @else {
content: "#{$i}";
}
}
}
================================================
FILE: scala.scala
================================================
object Scala extends App {
val fizzBuzz = Stream.from(1).map {
case n if n % 15 == 0 => "FizzBuzz"
case n if n % 5 == 0 => "Buzz"
case n if n % 3 == 0 => "Fizz"
case n => n
}
println(fizzBuzz.take(100).mkString("\n"))
}
================================================
FILE: scheme.scm
================================================
(define (fizzbuzz i n)
(display
(let ((divisbleBy5? (zero? (modulo i 5)))
(divisblyBy3? (zero? (modulo i 3))))
(cond ((and divisbleBy5? divisblyBy3?)
"FizzBuzz")
(divisbleBy5?
"Buzz")
(divisblyBy3?
"Fizz")
(else i))))
(newline)
(when (< i n)
(fizzbuzz (+ i 1) n)))
(fizzbuzz 1 100)
================================================
FILE: scilab.sce
================================================
for i=1:100
if modulo(i, 15) == 0 then
mprintf("%s\n", "FizzBuzz")
elseif modulo(i, 5) == 0 then
mprintf("%s\n", "Buzz")
elseif modulo(i, 3) == 0 then
mprintf("%s\n", "Fizz")
else
mprintf("%s\n", string(i))
end
end
================================================
FILE: sed.sh
================================================
#!/bin/bash
# check if we have GNU extensions
case $(sed --help 2>&1) in
# version with GNU extensions
# first sed invocation generates 100 lines of input
# second sed replaces each input line with its line number
# third sed replaces every third and fifth line with fizz and buzz
*GNU*) sed 's/.*/1/;h;:g;x;H;x;/\(1\n\)\{99\}/!b g;' <<<"" | sed '=;d' | sed '3~3s/.*/Fizz/;5~5s/[0-9]*$/Buzz/';;
# version without GNU extensions (third invocation has to be split into two and is a bit more complex)
*) sed 's/.*/1/;h;:g;x;H;x;/\(1\n\)\{99\}/!b g;' <<<"" | sed '=;d' | sed ':l;n;n;s/.*/Fizz/;n;b l' | sed ':l;n;n;n;n;s/[0-9]*$/Buzz/;n;b l';;
esac
================================================
FILE: shell.sh
================================================
#!/bin/sh
fizz_buzz () {
if [ `expr $1 % 15` -eq 0 ]
then
echo "FizzBuzz"
elif [ `expr $1 % 5` -eq 0 ]
then
echo "Buzz"
elif [ `expr $1 % 3` -eq 0 ]
then
echo "Fizz"
else
echo "$1"
fi
}
A=1
while [ $A -le 100 ]
do
fizz_buzz $A
A=`expr $A + 1`
done
================================================
FILE: spwn.spwn
================================================
fizz_buzz = (num: @number) =>
match 0 {
==(num%15): "fizzbuzz",
==(num%5): "buzz",
==(num%3): "fizz",
else: num as @string,
}
for i in 1..101 {
$.print(fizz_buzz(i))
}
================================================
FILE: sqlite3.sql
================================================
SELECT COALESCE(fizz || buzz, fizz, buzz, CAST(n AS CHAR(8))) AS fizzbuzz
FROM (
SELECT n0 + 3 * n3 + 9 * n9 + 27 * n27 + 81 * n81 AS n
FROM
(SELECT 0 AS n0 UNION ALL SELECT 1 UNION ALL SELECT 2 AS n0) AS N0,
(SELECT 0 AS n3 UNION ALL SELECT 1 UNION ALL SELECT 2 AS n3) AS N3,
(SELECT 0 AS n9 UNION ALL SELECT 1 UNION ALL SELECT 2 AS n9) AS N9,
(SELECT 0 AS n27 UNION ALL SELECT 1 UNION ALL SELECT 2 AS n27) AS N27,
(SELECT 0 AS n81 UNION ALL SELECT 1 AS n81) AS N81
) AS N
LEFT OUTER JOIN
(SELECT 3 AS fizzstep, CAST('Fizz' AS CHAR(4)) AS fizz) AS Fizz
ON n % fizzstep = 0
LEFT OUTER JOIN
(SELECT 5 AS buzzstep, CAST('Buzz' AS CHAR(4)) AS buzz) AS Buzz
ON n % buzzstep = 0
WHERE n BETWEEN 1 AND 100
ORDER BY n;
================================================
FILE: swift.swift
================================================
func FizzBuzz(num: Int) -> () {
if num % 15 == 0 {
print("FizzBuzz")
}
else if num % 5 == 0 {
print("Buzz")
}
else if num % 3 == 0 {
print("Fizz")
}
else {
print(num)
}
}
for i in 1...100 {
FizzBuzz(num: i)
}
================================================
FILE: tcl.tcl
================================================
proc fizzbuzz n {
switch -regexp [list $n [expr {$n % 3}]] {
{[05] 0} {list FizzBuzz}
{[^05] 0} {list Fizz}
{[05] [12]} {list Buzz}
default {list $n}
}
}
for {set i 1} {$i <= 100} {incr i} {
puts [fizzbuzz $i]
}
================================================
FILE: text.txt
================================================
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
================================================
FILE: typescript.ts
================================================
function fizzbuzz(num: number): string | number {
if (num % 15 === 0) return 'FizzBuzz';
if (num % 5 === 0) return 'Buzz';
if (num % 3 === 0) return 'Fizz';
return num;
}
for (let i: number = 1; i <= 100; i++) console.log(fizzbuzz(i));
================================================
FILE: vala.vala
================================================
void main (string[] args) {
for (long idx = 1; idx <= 100; idx++){
string res = "";
if(idx % 3 == 0){
res += "Fizz";
}
if(idx % 5 == 0){
res += "Buzz";
}
stdout.printf((res.length == 0
? idx.to_string() : res)+"\n");
}
}
================================================
FILE: visualbasic.vb
================================================
Module FizzBuzz
Function FizzBuzz(num As Integer) As String
Dim Fizz As Boolean = (num Mod 3 = 0)
Dim Buzz As Boolean = (num Mod 5 = 0)
If Fizz = True And Buzz = True Then
Return "FizzBuzz"
ElseIf Fizz = True Then
Return "Fizz"
ElseIf Buzz = True Then
Return "Buzz"
End If
Return num.ToString
End Function
Sub Main()
For i As Integer = 1 To 100
Console.WriteLine(FizzBuzz(i))
Next
Console.Read()
End Sub
End Module
================================================
FILE: whitespace.wh
================================================
================================================
FILE: zig.zig
================================================
// zig 0.6.0
const std = @import("std");
pub fn main() !void {
var i: i32 = 1;
while (i <= 100) : (i += 1) {
try fizzBuzz(i);
}
}
fn fizzBuzz(value: i32) !void {
const stdout = std.io.getStdOut().outStream();
var printed = false;
if (@rem(value, 3) == 0) {
try stdout.print("{}", .{"Fizz"});
printed = true;
}
if (@rem(value, 5) == 0) {
try stdout.print("{}", .{"Buzz"});
printed = true;
}
if (printed) {
try stdout.print("\n", .{});
} else {
try stdout.print("{}\n", .{value});
}
}
================================================
FILE: zinc.zn
================================================
//! zinc
library FizzBuzz { private { /* Fizz buzz in Zinc
*************************************************************************************
*
* http://www.wc3c.net/vexorian/zincmanual.html
*
************************************************************************************/
struct Main[] { private { static method onInit() {
integer Index = 1;
PreloadGenClear();
PreloadGenStart();
while(Index <= 100) {
if( ModuloInteger(Index, 15) == 0 ) {
Preload("\t\tFizz Buzz\t");
} else if( ModuloInteger(Index, 5) == 0 ) {
Preload("\t\tBuzz\t\t");
} else if( ModuloInteger(Index, 3) == 0 ) {
Preload("\t\tFizz\t\t");
} else {
Preload("\t\t" + I2S(Index) + "\t\t");
}
Index = Index + 1;
}
PreloadGenEnd("FizzBuzz\\Output.txt");
}}}
}}
//! endzinc
gitextract_1p_39tyn/ ├── .gitignore ├── Elm.elm ├── Haxe.hx ├── Jasmin.j ├── PowerShell.ps1 ├── README.md ├── ada_fizzbuzz.adb ├── apl.apl ├── applescript.applescript ├── arnoldc.arnoldc ├── assembly.asm ├── awk.awk ├── b.b ├── batch.bat ├── batsh.batsh ├── bc.bc ├── beta.bet ├── brainfuck.bf ├── buzzfizz.buzzfizz ├── c++.cpp ├── c.c ├── cesil.csl ├── chapel.chpl ├── clisp.lisp ├── clojure.clj ├── cobol.cbl ├── coffeescript.coffee ├── commodore_basic.bas ├── crystal.cr ├── csharp.cs ├── csharp10.cs ├── cuneiform.cfl ├── d.d ├── dafny.dfy ├── dart.dart ├── dc.dc ├── delphi.delphi ├── eiffel.e ├── elisp.el ├── elixir.exs ├── enkelt.e ├── escript.erl ├── forth.fth ├── fortran.f90 ├── fsharp.fs ├── gamemakerlanguage.gml ├── gdscript.gd ├── go.go ├── groovy.groovy ├── haskell.hs ├── holyc.HC ├── hoon.hoon ├── io.io ├── j.j ├── java.java ├── javascript.js ├── julia.jl ├── kotlin.kt ├── labyrinth.lab ├── lobster.lobster ├── lolcode.lol ├── lolpython.lol ├── lua.lua ├── matlab.m ├── mercury.m ├── mysql.sql ├── nim.nim ├── objc.m ├── ocaml.ml ├── octave.m ├── pascal.p ├── pawn.p ├── perl.pl ├── perl6.pl ├── php.php ├── pinecone.pn ├── pony.pony ├── postgresql.sql ├── potigol.poti ├── processing.pde ├── prolog.pl ├── pyret.arr ├── python.py ├── python2.py ├── python3.py ├── r.R ├── racket.rkt ├── rockstar.rock ├── ruby.rb ├── rust.rs ├── sassy-css.scss ├── scala.scala ├── scheme.scm ├── scilab.sce ├── sed.sh ├── shell.sh ├── spwn.spwn ├── sqlite3.sql ├── swift.swift ├── tcl.tcl ├── text.txt ├── typescript.ts ├── vala.vala ├── visualbasic.vb ├── whitespace.wh ├── zig.zig └── zinc.zn
SYMBOL INDEX (23 symbols across 14 files)
FILE: c++.cpp
function main (line 5) | int main(void)
function fizzbuzz (line 12) | void fizzbuzz(int num)
FILE: c.c
function main (line 5) | int main(void)
function fizzbuzz (line 14) | void fizzbuzz(int num)
FILE: csharp.cs
class Program (line 5) | public class Program
method FizzBuzz (line 7) | public static void FizzBuzz(int number)
method Main (line 27) | private static void Main(string[] args)
FILE: dart.dart
function fizzBuzz (line 1) | void fizzBuzz(int foo)
function main (line 13) | void main()
FILE: go.go
function fizzbuzz (line 10) | func fizzbuzz(num int) {
function main (line 22) | func main() {
FILE: java.java
class java (line 1) | public class java
method main (line 4) | public static void main(String[] args)
method fizzBuzz (line 11) | public static void fizzBuzz(int num)
FILE: javascript.js
function fizz_buzz (line 1) | function fizz_buzz(num) {
FILE: php.php
function fizzbuzz (line 3) | function fizzbuzz($num) {
FILE: python.py
function fizz_buzz (line 11) | def fizz_buzz(num):
FILE: python2.py
function fizz_buzz (line 3) | def fizz_buzz(num):
FILE: python3.py
function fizz_buzz (line 3) | def fizz_buzz(num):
FILE: ruby.rb
function fizz_buzz (line 3) | def fizz_buzz(num)
FILE: rust.rs
function fizzbuzz (line 1) | fn fizzbuzz(i: u8) {
function main (line 13) | fn main() {
FILE: typescript.ts
function fizzbuzz (line 1) | function fizzbuzz(num: number): string | number {
Condensed preview — 107 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (60K chars).
[
{
"path": ".gitignore",
"chars": 19,
"preview": ".DS_Store\n*.swp\n*~\n"
},
{
"path": "Elm.elm",
"chars": 571,
"preview": "import Html exposing (Html, div, text)\n\n\nfizzbuzz : Int -> List (Html a)\nfizzbuzz to =\n let\n current =\n "
},
{
"path": "Haxe.hx",
"chars": 370,
"preview": "class Haxe {\n static function main() {\n for (num in 0...100)\n {\n if (num % 15 == 0) {\n "
},
{
"path": "Jasmin.j",
"chars": 756,
"preview": ".class public Jasmin\n.super java/lang/Object\n\n.method public static main([Ljava/lang/String;)V\n\t.limit locals 1\n\t.limit "
},
{
"path": "PowerShell.ps1",
"chars": 255,
"preview": "for($i=1; $i -le 100; $i++)\n{\n\tif ($i % 3 -eq 0)\n\t{\n\t\tWrite-Host -NoNewline \"Fizz\"\n\t}\n\tif ($i % 5 -eq 0)\n\t{\n\t\tWrite-Host"
},
{
"path": "README.md",
"chars": 648,
"preview": "# FizzBuzz\nFizzBuzz in every programming language, inspired by [hello-world](https://github.com/leachim6/hello-world)\n\nI"
},
{
"path": "ada_fizzbuzz.adb",
"chars": 664,
"preview": "-- Note: GNAT complains if the unit is simply named \"Ada\" since that is a system\n-- unit. gnatmake silently refuses to "
},
{
"path": "apl.apl",
"chars": 52,
"preview": "{('FizzBuzz' 'Fizz' 'Buzz',⍵)[(0=15 3 5|⍵)⍳1]}¨⍳100\n"
},
{
"path": "applescript.applescript",
"chars": 332,
"preview": "#!/usr/bin/osascript\n\non fizzbuzz(i)\n if i mod 15 is 0 then\n return \"FizzBuzz\"\n else if i mod 3 is 0 then\n "
},
{
"path": "arnoldc.arnoldc",
"chars": 2144,
"preview": "IT'S SHOWTIME\n\n HEY CHRISTMAS TREE limit\n YOU SET US UP 100\n HEY CHRISTMAS TREE index\n YOU SET US UP"
},
{
"path": "assembly.asm",
"chars": 3643,
"preview": " ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Runs with nasm-2.11.05 ;;;;;;;;;;;;;;"
},
{
"path": "awk.awk",
"chars": 206,
"preview": "# run with `awk -f awk.awk`\nBEGIN{\n\tfor (i = 1; i <= 100; i++) {\n\t\tif (i % 15 == 0) print(\"FizzBuzz\")\n\t\telse if (i % 5 ="
},
{
"path": "b.b",
"chars": 247,
"preview": "fizzbuzz(n) {\n\textrn putchar;\n\tif (n % 3 == 0) putchar('Fizz');\n\tif (n % 5 == 0) putchar('Buzz');\n\tif ((n % 3) && (n % 5"
},
{
"path": "batch.bat",
"chars": 240,
"preview": "@echo off\nsetlocal enabledelayedexpansion\nfor /l %%i in (1,1,100) do (\nset /a mod3=%%i %% 3\nset /a mod5=%%i %% 5\nset pri"
},
{
"path": "batsh.batsh",
"chars": 255,
"preview": "function fizzbuzz(i) {\n if (i % 15 == 0) {\n println(\"FizzBuzz\");\n } else if (i % 3 == 0) {\n println(\"Fizz\");\n }"
},
{
"path": "bc.bc",
"chars": 264,
"preview": "/* Works with GNU bc */\n\ni = 1\n\nwhile (i <= 100) {\n if (i % 3 == 0) {\n if (i % 5 == 0) print \"FizzBuzz\\n\"\n if (i "
},
{
"path": "beta.bet",
"chars": 631,
"preview": "ORIGIN '~beta/basiclib/betaenv';\n-- program: Descriptor --\n(#\n i: @integer;\n fizzbuzz:\n (#\n number: @inte"
},
{
"path": "brainfuck.bf",
"chars": 4425,
"preview": "Code from https://github.com/Zomis/Brainduck/blob/master/src/main/resources/fizzbuzz.bf\n\nTAPE MEANINGS\n255 Start\n254 A F"
},
{
"path": "buzzfizz.buzzfizz",
"chars": 371,
"preview": "# Based on: https://esolangs.org/wiki/BuzzFizz#FizzBuzz\n\nif 100\\$a: # do nothing\nelse: # do nothing\n\n# $a is the counter"
},
{
"path": "c++.cpp",
"chars": 428,
"preview": "#include <iostream>\n\nvoid fizzbuzz(int);\n\nint main(void)\n{\n for (int i = 0; i <= 100; i++) {\n fizzbuzz(i);\n "
},
{
"path": "c.c",
"chars": 408,
"preview": "#include <stdio.h>\n\nvoid fizzbuzz(int);\n\nint main(void)\n{\n for (int i = 1; i <= 100; i++) {\n fizzbuzz(i);\n "
},
{
"path": "cesil.csl",
"chars": 1092,
"preview": " LOAD 0\n\n( PROCESS NEXT NUMBER\nMAIN ADD 1 \n STORE NUMBER\n "
},
{
"path": "chapel.chpl",
"chars": 247,
"preview": "proc fizzBuzz(i:int):string {\n if (i % 15 == 0) {\n return 'FizzBuzz';\n } else if (i % 3 == 0) {\n return 'Fizz';\n"
},
{
"path": "clisp.lisp",
"chars": 200,
"preview": "(defun fizzbuzz (n)\n (cond ((= (mod n 15) 0) \"FizzBuzz\")\n\t((= (mod n 3) 0) \"Fizz\")\n\t((= (mod n 5) 0) \"Buzz\")\n\t(t (write"
},
{
"path": "clojure.clj",
"chars": 301,
"preview": "(defn- fizz-buzz [n]\n\t(cond\n\t\t(zero? (rem n 15)) \"FizzBuzz\"\n\t\t(zero? (rem n 3)) \"Fizz\"\n\t\t(zero? (rem n 5)) \"Buzz\"\n\t\t:els"
},
{
"path": "cobol.cbl",
"chars": 1404,
"preview": " IDENTIFICATION DIVISION.\n PROGRAM-ID. FIZZ-BUZZ.\n DATA DIVISION.\n WORKING-STORAGE SECTION.\n "
},
{
"path": "coffeescript.coffee",
"chars": 227,
"preview": "fizz_buzz = (i) ->\n if i % 15 == 0\n return 'FizzBuzz'\n else if i % 5 == 0\n return 'Buzz'\n else if"
},
{
"path": "commodore_basic.bas",
"chars": 217,
"preview": "100 FOR X = 1 TO 100\n110 FLAG=1\n120 IF NOT (X-INT(X/3)*3)=0 THEN 150\n130 FLAG=0\n140 PRINT \"FIZZ\";\n150 IF NOT (X-INT(X/5)"
},
{
"path": "crystal.cr",
"chars": 209,
"preview": "def fizz_buzz(num : Int)\n if num % 15 == 0\n puts \"FizzBuzz\"\n elsif num % 3 == 0\n puts \"Fizz\"\n elsif num % 5 == "
},
{
"path": "csharp.cs",
"chars": 738,
"preview": "using System;\n\nnamespace FizzBuzz\n{\n public class Program\n {\n public static void FizzBuzz(int number)\n "
},
{
"path": "csharp10.cs",
"chars": 283,
"preview": "foreach (var i in Enumerable.Range(1, 100))\n Console.WriteLine(FizzBuzz(i));\n\nstatic string FizzBuzz(int number) =>\n "
},
{
"path": "cuneiform.cfl",
"chars": 1498,
"preview": "\n\n%%====================================================================\n%% Functions\n%%================================"
},
{
"path": "d.d",
"chars": 269,
"preview": "import std.stdio;\n\nint main() {\n foreach(i; 1..101) {\n fizzbuzz(i);\n } return 0;\n}\n\nvoid fizzbuzz(int i) {\n if (i "
},
{
"path": "dafny.dfy",
"chars": 337,
"preview": "method FizzBuzz(i: nat)\n{\n if i % 15 == 0 {\n print \"FizzBuzz\\n\";\n } else if i % 3 == 0 {\n print \"Fizz\\n\";\n } el"
},
{
"path": "dart.dart",
"chars": 273,
"preview": "void fizzBuzz(int foo) {\n if (foo % 15 == 0) {\n print(\"FizzBuzz\");\n } else if (foo % 5 == 0) {\n print(\"Buzz\");\n "
},
{
"path": "dc.dc",
"chars": 1264,
"preview": "# MACROS\n\n# The following macro prints \"Fizz\" (without a newline) and writes 1 to register\n# X. We store the macro in re"
},
{
"path": "delphi.delphi",
"chars": 302,
"preview": "program FizzBuzz;\n\n{$APPTYPE CONSOLE}\n\nuses SysUtils;\n\nvar\n i: Integer;\nbegin\n for i := 1 to 100 do\n begin\n if i m"
},
{
"path": "eiffel.e",
"chars": 446,
"preview": "class\n APPLICATION\n\ncreate\n make\n\nfeature {NONE}\n\n make\n do\n across\n 1 |..| 100 as i\n loop\n "
},
{
"path": "elisp.el",
"chars": 374,
"preview": ":;exec emacs -Q --script \"$0\" \"$@\"\n\n(defun fizzbuzz (n)\n (append (if (> n 1) (fizzbuzz (1- n)))\n (list (pcase "
},
{
"path": "elixir.exs",
"chars": 223,
"preview": "fizzbuzz = fn \n n when rem(n, 15) == 0 -> \"FizzBuzz\"\n n when rem(n, 3) == 0 -> \"Fizz\"\n n when rem(n, 5) == 0 -> \"Bu"
},
{
"path": "enkelt.e",
"chars": 281,
"preview": "def fizz_buzz($num) {\n om($num % 15 == 0) {\n skriv(\"FizzBuzz\")\n }\n anom($num % 5 == 0) {\n skriv(\""
},
{
"path": "escript.erl",
"chars": 436,
"preview": "#!/usr/bin/env escript\n\nmain(_) ->\n fizz_buzz(1, 101).\n\nfizz_buzz(Max, Max) ->\n ok;\nfizz_buzz(N, Max) when N rem 1"
},
{
"path": "forth.fth",
"chars": 315,
"preview": "#! /usr/bin/env gforth\n\n: FIZZBUZZ ( -- )\n 1\n 101 1 ?DO\n DUP 15 MOD 0= IF\n .\" FizzBuzz\" CR\n ELSE\n DUP "
},
{
"path": "fortran.f90",
"chars": 449,
"preview": "PROGRAM fizzbuzz\n IMPLICIT NONE\n INTEGER :: counter \n \n DO counter=0,100\n IF (MOD(counter,1"
},
{
"path": "fsharp.fs",
"chars": 192,
"preview": "let fizzbuzz (n : int) : string =\n match n % 3, n % 5 with\n | 0, 0 -> \"FizzBuzz\"\n | 0, _ -> \"Fizz\"\n | _, 0 -> \"Buzz\""
},
{
"path": "gamemakerlanguage.gml",
"chars": 279,
"preview": "for (var i = 1; i <= 100; i++)\n{\n if (i % 15 == 0) {\n draw_text(x,i*12.2,\"FizzBuzz\");\n } else if (i % 5 == "
},
{
"path": "gdscript.gd",
"chars": 227,
"preview": "extends Node\n\nfunc fizz_buzz(num):\n\tif(num % 15 == 0):\n\t\tprint(\"FizzBuzz\")\n\telif(num % 5 == 0):\n\t\tprint(\"Buzz\")\n\telif(nu"
},
{
"path": "go.go",
"chars": 345,
"preview": "// Author: Jinwei Zhao\n// Date: 2015.4.9\n\npackage main\n\nimport (\n\t\"fmt\"\n)\n\nfunc fizzbuzz(num int) {\n\tif num%3 == 0 && nu"
},
{
"path": "groovy.groovy",
"chars": 215,
"preview": "def fizzbuzz = {\n if(it % 15 == 0){\n \"FizzBuzz\"\n }else if(it % 3 == 0){\n \"Fizz\"\n }else if(it % 5 "
},
{
"path": "haskell.hs",
"chars": 228,
"preview": "module Main where\n\nfizzbuzz :: Int -> String\nfizzbuzz x\n | x `mod` 15 == 0 = \"FizzBuzz\"\n | x `mod` 3 == 0 = \"Fizz"
},
{
"path": "holyc.HC",
"chars": 385,
"preview": "/*\n * To use, you need TempleOS\n * In TempleOS, include the file\n * -> #include \"holyc.HC\"\n * and from the shell, call i"
},
{
"path": "hoon.hoon",
"chars": 199,
"preview": ":- %say\n|= [^ ~ ~]\n :- %noun\n %+ turn (gulf [1 101])\n |= a=@\n =+ q=[=(0 (mod a 3)) =(0 (mod a 5))]\n ?+ "
},
{
"path": "io.io",
"chars": 245,
"preview": "#io language http://iolanguage.org/\n\nFizzBuzz := method(a,\n\tif (a % 15 == 0,\n\t\twriteln(\"FizzBuzz\"), \n\t\tif (a % 3 == 0,\n\t"
},
{
"path": "j.j",
"chars": 54,
"preview": "(\":[^:(''-:])(('Fizz'#~0=3&|),'Buzz'#~0=5&|))\"0>:i.100"
},
{
"path": "java.java",
"chars": 491,
"preview": "public class java\n{\n\n public static void main(String[] args)\n {\n for (int i=1; i<=100; i++) {\n f"
},
{
"path": "javascript.js",
"chars": 307,
"preview": "function fizz_buzz(num) {\n if (num % 15 === 0) {\n console.log(\"FizzBuzz\");\n } else if (num % 5 === 0) {\n "
},
{
"path": "julia.jl",
"chars": 217,
"preview": "function FizzBuzz(num)\n if num % 15 == 0\n println(\"FizzBuzz\")\n elseif num % 5 == 0\n println(\"Buzz\")\n elseif num"
},
{
"path": "kotlin.kt",
"chars": 216,
"preview": "fun main(args: Array<String>) {\n (1..100).forEach {\n println(when (0) {\n it % 3 -> \"Fizz${if (it % "
},
{
"path": "labyrinth.lab",
"chars": 823,
"preview": " )::}_101-@ Increment the counter, leave a copy on aux, check if we're below 101, otherwise terminate.\n \" { "
},
{
"path": "lobster.lobster",
"chars": 283,
"preview": "// FizzBuzz in [lobster](https://www.strlen.com/lobster/)\n\ndef fizz(x):\n if x % 15 == 0:\n print \"FizzBuzz\"\n "
},
{
"path": "lolcode.lol",
"chars": 594,
"preview": "HAI 1.2\n\nIM IN YR FIZZBUZZLOOP UPPIN YR LOOPVAR TIL BOTH SAEM LOOPVAR AN 100\n\n I HAS A FIZZBUZZVAR ITZ SUM OF LOOPVAR A"
},
{
"path": "lolpython.lol",
"chars": 477,
"preview": "SO IM LIKE MODDIN WIT X AND Y OK?\n I CAN HAS X SMASHES NICELY INTO Y\n U TAKE X TAKE AWAY Y OF THOSE I\n\nSO IM LIKE FIZZ"
},
{
"path": "lua.lua",
"chars": 268,
"preview": "function fizz_buzz (n)\n if n % 3 == 0 then\n if n % 5 == 0 then\n io.write('FizzBuzz')\n else\n io.write('F"
},
{
"path": "matlab.m",
"chars": 229,
"preview": "for inum = 1:100\n fizzbuzz = '';\n if mod(inum,3) == 0\n\tfizzbuzz = [fizzbuzz 'Fizz'];\n end\n if mod(inum,5) == 0\n\tfizz"
},
{
"path": "mercury.m",
"chars": 1083,
"preview": ":- module mercury. %% Mercury requires that the module name is the same as the\n %% file name.\n\n:- inte"
},
{
"path": "mysql.sql",
"chars": 525,
"preview": "select\n case\n when n %15 = 0 then 'FizzBuzz'\n when n %3 = 0 then 'Fizz'\n when n %5 = 0 then 'Buzz'\n else "
},
{
"path": "nim.nim",
"chars": 219,
"preview": "func fizzbuzz(n: int): string =\n if n mod 15 == 0:\n result = \"FizzBuzz\"\n elif n mod 3 == 0:\n result = \"Fizz\"\n e"
},
{
"path": "objc.m",
"chars": 592,
"preview": "/*\n Build on OS X:\n clang -framework Foundation -fobjc-arc objc.m -o objc\n \n Build on Linux with GNUstep:\n clang `gnuste"
},
{
"path": "ocaml.ml",
"chars": 278,
"preview": "let fizz_buzz n =\n if n mod 5 == 0 && n mod 3 == 0 then print_string \"FizzBuzz\\n\"\n else if n mod 5 == 0 then print_str"
},
{
"path": "octave.m",
"chars": 369,
"preview": "% Running code - http://ideone.com/uGgJMt\n% Must mention coursera ML course by Andrew NG, did it more than 3 years back,"
},
{
"path": "pascal.p",
"chars": 280,
"preview": "program FizzBuzz(output);\nvar\n i : integer;\nbegin\n for i := 1 to 100 do\n if i mod 15 = 0 then\n writeln("
},
{
"path": "pawn.p",
"chars": 333,
"preview": "fizzBuzz(num) {\n\tif (num % 3 == 0 && num % 5 == 0) {\n print(\"FizzBuzz\\n\")\n } else if (num % 3 == 0) {\n p"
},
{
"path": "perl.pl",
"chars": 214,
"preview": "#!/usr/bin/env perl\nfor (my $i = 1; $i < 101; $i++) {\n\tif ($i % 15 == 0) {\n\t\tprint \"FizzBuzz\\n\";\n\t} elsif ($i % 3 == 0) "
},
{
"path": "perl6.pl",
"chars": 178,
"preview": "#!/usr/bin/env perl6\nfor 1 .. 100 {\n\tif ($_ % 15 == 0) {\n\t\tsay \"FizzBuzz\";\n\t} elsif ($_ % 3 == 0) {\n\t\tsay \"Fizz\";\n\t} els"
},
{
"path": "php.php",
"chars": 330,
"preview": "<?php\n\nfunction fizzbuzz($num) {\n if ($num % 15 == 0) {\n print(\"FizzBuzz\" . PHP_EOL);\n } else if ($num % 5 "
},
{
"path": "pinecone.pn",
"chars": 389,
"preview": "# FizzBuzz\n\n# call the function defined below\nfizzBuzz: 1, 100\n\n# define the FizzBuzz function\nfizzBuzz :: {start: Int, "
},
{
"path": "pony.pony",
"chars": 328,
"preview": "use \"collections\"\n\nactor Main\n new create(env: Env) =>\n for i in Range[I32](1, 100) do\n env.out.print(fizzbuzz("
},
{
"path": "postgresql.sql",
"chars": 458,
"preview": "--http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/11608\n--Runs with postgresql 9.3\n--This will not match with"
},
{
"path": "potigol.poti",
"chars": 164,
"preview": "para i de 1 até 100 faça\n\tse i mod 15 == 0\n\t\tescreva \"FizzBuzz\"\n\tsenãose i mod 5 == 0\n\t\tescreva \"Buzz\"\n\tsenãose i mod 3 "
},
{
"path": "processing.pde",
"chars": 243,
"preview": "void setup() {\n for (int i=1; i<=100; i++) {\n if (i % 15 == 0) {\n println(\"FizzBuzz\");\n } else if (i % 5 == "
},
{
"path": "prolog.pl",
"chars": 560,
"preview": "% Clauses to print FizzBuzz for values 1 up to N\nfizzBuzzToN(N) :- var(N),\n writeln(\"Missing argument\").\nfizzBuzzToN("
},
{
"path": "pyret.arr",
"chars": 662,
"preview": "fun multiple-of(n :: Number, m :: Number) -> Boolean:\n doc: ```Consumes numbers `n` and `m` and produces true if `n` is"
},
{
"path": "python.py",
"chars": 399,
"preview": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\ntry:\n range = xrange\nexcept NameError: # Python2's xra"
},
{
"path": "python2.py",
"chars": 251,
"preview": "#!/usr/bin/env python2\n\ndef fizz_buzz(num):\n if num % 15 == 0:\n print \"FizzBuzz\"\n elif num % 5 == 0:\n "
},
{
"path": "python3.py",
"chars": 254,
"preview": "#!/usr/bin/env python3\n\ndef fizz_buzz(num):\n if num % 15 == 0:\n print(\"FizzBuzz\")\n elif num % 5 == 0:\n "
},
{
"path": "r.R",
"chars": 295,
"preview": "fizz_buzz <- function(num_array=seq_len(100L)){\nresult_array <- Map(function(r,n){cat(paste0(ifelse(r=='',n,r),'\\n'))},\n"
},
{
"path": "racket.rkt",
"chars": 406,
"preview": "#lang racket\n\n(define (fizzbuzz n)\n (if (= 0 n)\n #t\n (begin (fizzbuzz (- n 1))\n (if (= 0 (remainder n 1"
},
{
"path": "rockstar.rock",
"chars": 580,
"preview": "Midnight takes your heart and your soul\nWhile your heart is as high as your soul\nPut your heart without your soul into y"
},
{
"path": "ruby.rb",
"chars": 205,
"preview": "#!/usr/bin/env ruby\n\ndef fizz_buzz(num)\n result = ''\n result += 'Fizz' if (num % 3).zero?\n result += 'Buzz' if (num %"
},
{
"path": "rust.rs",
"chars": 268,
"preview": "fn fizzbuzz(i: u8) {\n if i % 15 == 0 {\n println!(\"FizzBuzz\");\n } else if i % 3 == 0 {\n println!(\"Fizz\");\n } els"
},
{
"path": "sassy-css.scss",
"chars": 433,
"preview": "// This output is not the traditional output\n// expected for FizzBuzz but it does generate \n// CSS classes for appending"
},
{
"path": "scala.scala",
"chars": 265,
"preview": "object Scala extends App {\n \n val fizzBuzz = Stream.from(1).map {\n case n if n % 15 == 0 => \"FizzBuzz\"\n case n i"
},
{
"path": "scheme.scm",
"chars": 380,
"preview": "(define (fizzbuzz i n)\n (display\n (let ((divisbleBy5? (zero? (modulo i 5)))\n (divisblyBy3? (zero? (modulo i 3"
},
{
"path": "scilab.sce",
"chars": 271,
"preview": "for i=1:100\n if modulo(i, 15) == 0 then\n mprintf(\"%s\\n\", \"FizzBuzz\") \n elseif modulo(i, 5) == 0 then\n "
},
{
"path": "sed.sh",
"chars": 653,
"preview": "#!/bin/bash\n\n# check if we have GNU extensions\ncase $(sed --help 2>&1) in\n\n# version with GNU extensions\n# first sed inv"
},
{
"path": "shell.sh",
"chars": 294,
"preview": "#!/bin/sh\n\nfizz_buzz () {\n if [ `expr $1 % 15` -eq 0 ]\n then\n echo \"FizzBuzz\"\n elif [ `expr $1 % 5` -eq 0 ]\n then"
},
{
"path": "spwn.spwn",
"chars": 213,
"preview": "fizz_buzz = (num: @number) =>\n match 0 {\n ==(num%15): \"fizzbuzz\",\n ==(num%5): \"buzz\",\n ==(num%3)"
},
{
"path": "sqlite3.sql",
"chars": 837,
"preview": "SELECT COALESCE(fizz || buzz, fizz, buzz, CAST(n AS CHAR(8))) AS fizzbuzz\n FROM (\n SELECT n0 + 3 * n3 + 9 * n9 + 2"
},
{
"path": "swift.swift",
"chars": 278,
"preview": "func FizzBuzz(num: Int) -> () {\n if num % 15 == 0 {\n print(\"FizzBuzz\")\n }\n else if num % 5 == 0 {\n "
},
{
"path": "tcl.tcl",
"chars": 257,
"preview": "proc fizzbuzz n {\n switch -regexp [list $n [expr {$n % 3}]] {\n {[05] 0} {list FizzBuzz}\n {[^05] 0} {lis"
},
{
"path": "text.txt",
"chars": 413,
"preview": "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz"
},
{
"path": "typescript.ts",
"chars": 245,
"preview": "function fizzbuzz(num: number): string | number {\n if (num % 15 === 0) return 'FizzBuzz';\n if (num % 5 === 0) return '"
},
{
"path": "vala.vala",
"chars": 312,
"preview": "void main (string[] args) {\n\n for (long idx = 1; idx <= 100; idx++){\n string res = \"\";\n\n if(idx % 3 == "
},
{
"path": "visualbasic.vb",
"chars": 589,
"preview": "Module FizzBuzz\r\n\r\n Function FizzBuzz(num As Integer) As String\r\n Dim Fizz As Boolean = (num Mod 3 = 0)\r\n "
},
{
"path": "whitespace.wh",
"chars": 358,
"preview": " \t\n\n \n \n \n\t \n \t\t\n\t \t\t\n\t \t\n\n \n \n \t \t\n\t \t\t\n\t \t\n\n \t \n \n\t\n\t \t\t\n\n \n \t \t \n\t\n \t\n\t \n \t\t \t \t\n\t"
},
{
"path": "zig.zig",
"chars": 541,
"preview": "// zig 0.6.0\n\nconst std = @import(\"std\");\n\npub fn main() !void {\n var i: i32 = 1;\n while (i <= 100) : (i += 1) {\n "
},
{
"path": "zinc.zn",
"chars": 947,
"preview": "//! zinc\nlibrary FizzBuzz { private { /* Fizz buzz in Zinc\n*************************************************************"
}
]
About this extraction
This page contains the full source code of the zenware/FizzBuzz GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 107 files (50.5 KB), approximately 18.0k tokens, and a symbol index with 23 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.