# 1, 2, Fizz, 4, Buzz

## Introduction

In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other catalogue challenges, there is "Hello World!" and "Is this number a prime?".

## Challenge

Write a program that prints the decimal numbers from 1 to 100 inclusive. 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”.

## Output

The output will be a list of numbers (and Fizzes, Buzzes and FizzBuzzes) separated by a newline (either \n or \r\n). A trailing newline is acceptable, but a leading newline is not. Apart from your choice of newline, the output should look exactly like this:

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


The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

## Further Rules

• This is not about finding the language with the shortest approach for playing FizzBuzz, this is about finding the shortest approach in every language. Therefore, no answer will be marked as accepted.

• Submissions are scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score--if in doubt, please ask on Meta.

• Nothing can be printed to STDERR.

• Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program generates FizzBuzz output, then congrats for paving the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

• If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Alphuck and ???), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

• Because the output is fixed, you may hardcode the output (but this may not be the shortest option).

• You may use preexisting solutions, as long as you credit the original author of the program.

• Standard loopholes are otherwise disallowed.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

## Catalogue

var QUESTION_ID=58615;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=30525;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.has_more)more_answers=false;comment_page=1;getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:true,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}getAnswers();var SCORE_REG=/<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,});else console.log(body)});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery('<a>'+lang+'</a>').text();languages[lang]=languages[lang]||{lang:a.language,lang_raw:lang.toLowerCase(),user:a.user,size:a.size,link:a.link}});var langs=[];for(var lang in languages)if(languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function(a,b){if(a.lang_raw>b.lang_raw)return 1;if(a.lang_raw<b.lang_raw)return-1;return 0});for(var i=0;i<langs.length;++i){var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}
body{text-align:left!important}#answer-list{padding:10px;width:290px;float:left}#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table>

• Nothing can be printed to STDERR. Is this true only when running, or also when compiling (assuming that is a separate step?) – AShelly Sep 24 '15 at 20:47
• @AShelly Only when running – Beta Decay Sep 24 '15 at 20:48
• I’m not sure I like the fact that you hardcoded the 100 into the challenge. That way, a program that just generates the expected output is a valid entry, but is not interesting for this challenge. I think the challenge should expect the program to input the number of items to output. – Timwi Sep 24 '15 at 23:28
• @Timwi While I agree that it would make it (only slightly) more interesting, I've very often seen FizzBuzz as strictly 1 to 100 (on Wikipedia and Rosetta Code, for example). If the goal is to have a "canonical" FB challenge, it makes sense. – Geobits Sep 25 '15 at 0:50
• A "vanilla fizzbuzz" sounds delicious. – iamnotmaynard Sep 25 '15 at 15:12

# R, 88837771 70 bytes

I'm sure that this can be improved ... and it was with credit to @flodel. A further couple of bytes saved thanks to a suggestion from @njnnja and another from @J.Doe

x=y=1:100;y[3*x]='Fizz';y[5*x]='Buzz';y[15*x]='FizzBuzz';write(y[x],1)

• A cat answer. The mouse is above :) – Silviu Burcea Sep 25 '15 at 10:36
• I found a bit better: x=1:100;i=!x%%3;j=!x%%5;x[i]="Fizz";x[j]="Buzz";x[i&j]="FizzBuzz";cat(x,sep="\n") – flodel Sep 28 '15 at 2:13
• @njnnja Thanks for the suggestion. I implemented it with a write rather than cat though – MickyT Sep 28 '15 at 19:07
• Necromancy here! The write call can take a 1 instead of a an empty string so x=y=1:100;y[3*x]='Fizz';y[5*x]='Buzz';y[15*x]='FizzBuzz';write(y[x],1) is a trivial 1 byte golf for 70 bytes. – J.Doe Oct 1 '18 at 13:00
• 68 bytes. The bytecount includes three unprintable backspaces, and it doesn't work correctly in TIO. – J.Doe Oct 4 '18 at 21:41

# PHP, 54 bytes

<?for(;$i++<100;)echo[Fizz][$i%3].[Buzz][$i%5]?:$i,~õ;


Valid for v5.5 onwards. The õ is character 245, a bit inverted \n.

I assume the default interpreter settings, as they are without any ini. If you are uncertain, you may disable your local ini with -n as in php -n fizzbuzz.php.

A version which will run error-free with absolutely any configuration file is 62 bytes:

<?php
for(;$i++<100;)echo@([Fizz][$i%3].[Buzz][$i%5]?:$i),"
";

• The STFU operator @ does not necessarily mean that the code is error free. – sitilge Sep 28 '15 at 12:42
• ideone.com/5rfNt0 – Kzqai Sep 30 '15 at 6:55
• @Kzqai ideone.com/0zRA9e short_open_tag is off, E_NOTICE is on. Neither of these are default settings. – primo Sep 30 '15 at 11:46
• I'm getting a bunch of errors on 3v4l.org – a coder Jan 27 '16 at 23:42
• @acoder relevant meta post. 3v4l.org seems useful. – primo Jan 28 '16 at 9:32

## Hexagony, 112 bytes

d{$>){*./;\.}<._.zi...><{}.;/;$@-/=.*F;>8M'<$<..'_}....>.3'%<}'>}))'%<..._>_.'<$.....};u..}....{B.;..;.!<'..>z;/


After unfolding and with colour-coded execution paths:

Diagram created with Timwi's HexagonyColorer.

Finally got around to finishing this. I had written an ungolfed solution weeks ago, but wasn't entirely happy with it so I never actually golfed it. After revisiting it the other day, I found a way to simplify the ungolfed solution slightly, and while I think there might still be a better way to approach the problem in general, I decided to golf it this time. The current solution is far from optimal, and I think it should actually fit in side-length 6 instead of 7. I'll give this a go over the next days, and when I'm happy with the result will add a full explanation.

## ArnoldC, 842 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE a
YOU SET US UP 100
HEY CHRISTMAS TREE b
YOU SET US UP 0
HEY CHRISTMAS TREE r
YOU SET US UP 0
STICK AROUND a
GET TO THE CHOPPER b
HERE IS MY INVITATION 101
GET DOWN a
ENOUGH TALK
GET TO THE CHOPPER r
HERE IS MY INVITATION b
I LET HIM GO 15
ENOUGH TALK
BECAUSE I'M GOING TO SAY PLEASE r
GET TO THE CHOPPER r
HERE IS MY INVITATION b
I LET HIM GO 3
ENOUGH TALK
BECAUSE I'M GOING TO SAY PLEASE r
GET TO THE CHOPPER r
HERE IS MY INVITATION b
I LET HIM GO 5
ENOUGH TALK
BECAUSE I'M GOING TO SAY PLEASE r
TALK TO THE HAND b
BULLSHIT
TALK TO THE HAND "Buzz"
YOU HAVE NO RESPECT FOR LOGIC
BULLSHIT
TALK TO THE HAND "Fizz"
YOU HAVE NO RESPECT FOR LOGIC
BULLSHIT
TALK TO THE HAND "FizzBuzz"
YOU HAVE NO RESPECT FOR LOGIC
GET TO THE CHOPPER a
HERE IS MY INVITATION a
GET DOWN 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED


First try at golfing, I think this is as bad as it gets (both language and golfing).

• YOU HAVE NO RESPECT FOR LOGIC lol, this is a great language ;) – ETHproductions Mar 10 '16 at 17:39
• Hahahaha!!! You should've made it a method, worse bytecount, better phrases ;). – Magic Octopus Urn Oct 13 '16 at 17:46

# JavaScript, 65 bytes

for(i=0;i++<100;console.log((i%3?'':'Fizz')+(i%5?'':'Buzz')||i));


The shortest approach I've found yet. Perhaps there's a better one; suggestions are welcome. This was originally flagged ES6, but this works in ES5, and to my knowledge there's not a shorter way with ES6 features.

Here's another attempt, using .slice and some complicated maths for a total of 66 bytes:

for(i=0;i++<100;console.log('FizzBuzz'.slice(i%3&&4,i%5?4:8)||i));


(Thanks to Ben Fortune for a couple of handy tricks!)

• You could shorten your second attempt to for(i=0;i++<100;console.log('FizzBuzz'.slice(i%3&&4,i%5?4:8)||i)); – Ben Fortune Sep 25 '15 at 10:13
• If you move console.log(...) outside for(...;...;...), you can drop the semicolon. – Dennis Oct 3 '15 at 15:54
• This is old, but ES6 plus Dennis= 61 bytes: for(i=0;i++<100;)console.log(i%3?i:'fizz'+${i%5?'':'Buzz'}) I can't make it a code block because the template string won't show up correctly – Generic User Nov 15 '15 at 18:23 • @GenericUser That doesn't quite work; it never prints Buzz by itself. To insert code with backticks in it, just use 2 or 3 backticks on each end. – ETHproductions Nov 15 '15 at 18:31 # TrumpScript, 938 bytes As always nothing is, 1000001 minus 1000000; And Putin is, 1000003 minus 1000000; great Just as Trump is, 1000005 minus 1000000; even better Also as America is, Putin times Trump; the best Most importantly Ivanka is, 1000101 minus 1000000; And believe me that Hillary is nothing As long as, Hillary thinks less of Ivanka;: China is friends with Hillary Democrats are idiots like Hillary Obama is in line with Hillary As long as, China thinks its more than America;: Make China, China minus America;! As long as, Democrats fear more Trump;: Make Democrats, Democrats minus Trump;! As long as, Obama gets more arsenal against Putin;: Make Obama, Obama minus Putin;! If everybody thinks, America is China?;: Say "FizzBuzz"! Otherwise: if we ask, Democrats are Trump?;: Say "Buzz"! Otherwise: what if, Obama is Putin?;: Say "Fizz"! Otherwise do this: tell Hillary all her lies!!! Hillary is, as always Hillary plus nothing;! America is great.  Try it online! I was quite bored... Not too efficient, but fun! Pseudocode: var nothing = 1, Putin = 3, Trump = 5, America = Putin * Trump, Ivanka = 101, Hillary = nothing; while Hillary < Ivanka var China = Democrats = Obama = Hillary; while China > America China = China - America; while Democrats > Trump Democrats = Democrats - Trump; while Obama > Putin Obama = Obama - Putin; if China == America print "FizzBuzz"; else if Democrats == Trump print "Buzz"; else if Obama == Putin print "Fizz"; else print Hillary; Hillary = Hillary + nothing; America is great.  # Vim, 44 bytes 33o<CR>Fizz<CR><Esc>qqABuzz<Esc>5kq19@q:%s/^$/\=line('.')<CR>

On vimgolf.com we have the classic Remember FizzBuzz?, which is similar to this, but keeps the numbers on all the lines. There's also Neither Fizz nor Buzz, which uses a similar format, but provides a useful input file. Those small differences drastically change the optimal solution. I did exactly this same variation 2 years ago in the edit to this reddit post. I had to check whether visual increment (not available back then) creates an improvement, like it has for the other variations, but it looks like it hasn't.

• 33o<CR>Fizz<CR><Esc>: Create the Fizz lines AND the blank lines with a simple insert mode repeat. Much quicker than a macro. AFAIK first discovered by @KersonHsiao in the vimgolf.com version, and used by every top solution since.
• qqABuzz<Esc>5kq19@q: A very simple macro appends the Buzzes.
• :%s/^$/\=line('.')<CR>: Replaces all blank lines with that line's line number. The expression replacement is very long, so this tactic is rarely used in vimgolf, but the alternatives are all worse. # Julia, 64 bytes for i=1:100 x="Fizz"^(i%3<1)*"Buzz"^(i%5<1);println(x>""?x:i)end  # Common Lisp, 123 116 (dotimes(i 100)(loop for(m s)in'((3"Fizz")(5"Buzz"))if(=(mod(1+ i)m)0)do(princ s))(do()((fresh-line))(princ(1+ i))))  ### Pretty-printed (dotimes (i 100) (loop for (m s) in '((3 "Fizz") (5 "Buzz")) if (= (mod (1+ i) m) 0) do (princ s)) (do () ((fresh-line)) (princ (1+ i))))  ### The do/fresh-line trick The inner loop iterates over ((3 "Fizz") (5 "Buzz")) for each i and, according to the result of the two consecutive mod operations, eventually prints: • nothing • or Fizz • or Buzz • or FizzBuzz fresh-line is a nice little function that as far as I know is only found in Common Lisp. It adds a newline only if necessary, and returns T only when the newline was added. For the above situations, according to whether we printed something or not, the return values of (fresh-line) are thus respectively: • NIL • T • T • T So I know that the integer must be printed only when we did not print a fresh-line. But if I print the integer, I must also print a newline after it. That's why there is a DO. DO is a basic yet almighty looping construct that iterates until a condition is met. Here, the condition is the return value of (fresh-line). It it tested before each iteration of the body of the loop, notably the first one. So if the test returns T, then we exit the DO. Otherwise, we execute the body, which prints the integer. Then, we execute the test once again and this time, it returns T because current line is "dirty" (there is an integer printed now). • Clever! I don't think I can change my CL answer to beat it. – nanny Sep 25 '15 at 16:42 • @nanny If that can comfort you, I don't think I can either. I saw your answer, it was hard to beat. – coredump Sep 25 '15 at 16:47 • Great answer. I learnt some from it and don't understand it fully yet. However I think I've managed to beat you by 13 bytes using different method. – PrzemysławP Feb 17 '17 at 22:45 ## Snowman 1.0.2, 97 chars )1vn101nR:du*_/3NmO0eQ)(#5NmO0eQ}~(~%@or(%nO?_/)#%@{%@tS?)aRsP@@"Fizz"_aRsP\"Buzz"aRsP?)10wRsP;aE  How does it work, you ask? ... I have no idea. I might edit in a full explanation at some point if I ever decide to try to understand this again. (Pulled directly from Snowman's examples directory.) # MoonScript, 83 82 bytes [print(i%15==0and"FizzBuzz"or(i%3==0and"Fizz")or(i%5==0and"Buzz")or i) for i=1,100]  • Welcome to Programming Puzzles & Code Golf! – Dennis Sep 26 '15 at 5:27 # C++, 130126119 115 #include<iostream> int i;int main(){for(auto&o=std::cout;++i<101;o<<'\n')i%3?o:o<<"Fizz",i%5?i%3?o<<i:o:o<<"Buzz";}  ## Mathematica, 83757367 62 bytes Print/@(#/.(##&[15#->FizzBuzz,3#->Fizz,5#->Buzz]&)/@#&@Range@100)  I do not think that this could be golfed any further. Thanks to branislav for helping me golf this. • golf it down to 66 bytes by first removing all quotation marks, second using ...\\Column instead of Print/@(...) – branislav Oct 30 '15 at 16:39 • then how about Print/@% – branislav Nov 2 '15 at 5:30 • @branislav It doesn't end up saving any bytes. – LegionMammal978 Nov 2 '15 at 11:24 • You mean Mathematica doesn't have a FizzBuzz builtin? – Mego Nov 15 '15 at 5:02 • I should make it clear that I don't think that not working in the up-to-date version in any way invalidates this answer! But I'm interested to know what the best solution is in 11. – A Simmons Jan 20 '17 at 17:10 # Brainfuck, 425 bytes -[>+>+<<-----]>--->-->++++++++++>->++++++++++>+++++++++>>>+++>>>+++++>>>>>-[<+<+>>-------]<---<--->---->>-[<++>-----]<+++>>>----[<+++<+++>>--]<-----<<<<<<<<<<<<<<[<++++++++++[>>[->>-<]>+[->>>>>-[<<<-[<<<<<<<<.>>>>>>>>>>-<]>+[->]<<+>>>>>-<]>+[->]<<+<<<<]>-[>>>-[<<<<<<<<<<.>>>>>>>>>>>>-<]>+[->]<<+<-<]>+[>>>>>.>>.>..<<<<<<<<<+++>->]>-[>>-<]>+[>>>.>>>.<..<<<<<<+++++>->]<<<<<<<<<<<<+>.>-]<<----------<+>>>>-]>>>>>>>>>>>.>>>.<..  Try it online! ## Explanation Cell indexes in comments are in hexadecimal to match numbering in bfdev debug view. # ##################### # ##### VARIABLES ##### # ##################### # C1 & C2: 48 (ascii 0) -[>+>+<<-----]>--->--> # C3: 10 (ascii LF) ++++++++++> # C4: Singles counter -> # C5: Tens counter ++++++++++> # C6: is1to9 if countdown +++++++++> # C7: 0 to enter/exit is1to9, or 1 to enter is10to99 > # C8: 0 to not enter is10to99 > # C9: isMultiOf3 if countdown +++> # CA: 0 to exit isMultiOf3, or 1 to enter !isMultiOf3 > # CB: 0 to not enter !isMultiOf3 > # CC: isMultiOf5 if countdown +++++> # CD: 0 to exit isMultiOf5, or 1 to enter !isMultiOf5 > # CE: 0 to not enter !isMultiOf5 > # CF: 70 F, and put C13 to 70 >>-[<+<+>>-------]<---<---> # C10: 66 - ascii B ----> # C11: 105 - ascii i >-[<++>-----]<+++> # C12: 122 - ascii z, and put C16 to 122 >>----[<+++<+++>>--]< # C13: 117 - ascii u ----- # Goto C5 <<<<<<<<<<<<<< # ################# # ##### LOGIC ##### # ################# # While C5 (tens counter): Print 1-99 [ # Restore C4: singles counter <++++++++++ # For 0 to 9, using singles counter [ # Goto C6 >> # If is1to9 [ # Decrement is1to9 countdown - # Prepare else condition at C8 >>-< ] # Goto C7 or C8 >+ # Else If C7: is10to99 [ # Decrement C7 - # Goto CC >>>>>- # If is not multi of 5 [ # Goto C9 <<<- # If is not multi of 3 [ # Print C1: tens <<<<<<<<. # Prepare else condition at CB >>>>>>>>>>- # Goto CA < ] # Goto CA or CB >+ # Else If is multi of 3 [ # Goto CA, restore, goto CB -> ] # Goto C9 and restore <<+ # Prepare else condition at C1E >>>>>- # Goto C1D < ] # Goto CD or CE >+ # Else If is multi of 5 [ # Goto CD, restore, goto CE -> ] # Goto CC and restore <<+ # Goto C8 <<<< ] # Goto C9 >- # If is not multi of 3 [ # Goto CC >>>- # If is not multi of 5 [ # Print C2: singles <<<<<<<<<<. # Prepare else condition at CE >>>>>>>>>>>>- # Goto CD < ] # Goto CD or CE >+ # Else If is multi of 5 [ # Goto CD, restore, goto CE -> ] # Goto CC and restore <<+ # Prepare else condition at CB <- # Goto CA < ] # Goto CA or CB >+ # Else If is multi of 3 [ # Print Fizz >>>>>.>>.>.. # Goto C9 (If is not multi of 3) <<<<<<<<< # Restore C9 +++ # Goto CA, decrease, goto CB >-> ] # Goto CC >- # If is not multi of 5 [ # Prepare else condition at CE >>- # Goto CD < ] # Goto CD or CE >+ # Else If is multi of 5 [ # Goto C10 and print Buzz >>>.>>>.<.. # Goto CC (If is not multi of 5) and restore <<<<<<+++++ # Goto CD, decrease, goto CE >-> ] # Goto C2: singles, and increment <<<<<<<<<<<<+ # Print C3: LF >. # Decrement C4: singles counter >- ] # Restore C2: singles ascii <<---------- # Increment C1: tens ascii <+ # Goto C5 (tens counter) and decrement it >>>>- ] # Goto C10 and print Buzz >>>>>>>>>>>.>>>.<..  • Thought I'd let you know I beat your score ;) – Jo King Nov 24 '17 at 9:43 # Brainfuck, 16321 3602 1597 Almost as short as Java. This is just the trivial answer generated by another program, This is still a computer generated answer, but I am sure there are way shorter solutions! The general idea is initializing the cells to 4 B F i u z. If the program has to output a number, it just goes to the first cell and manipualtes it, if it is one of the letters, it will just jump to the corresponding cell and output it. ++++++++++<<+++++++[>+++++++<-]>[>>+>+>+>++>++>++<<<<<<<-]>>+++>+++++++++++++++++>+++++++++++++++++++++>+++++++>+++++++++++++++++++>++++++++++++++++++++++++<<<<<---.<.>+.<.>>>.>.>>..<<<<<<.>++.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>+++.<.>+.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>-------..<.>>>.>.>>..<<<<<<.>.++.<.>--.+++.<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>---.+++++.<.>-----.++++++.<.>>>.>.>>..<<<<<<.>------.++++++++.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>-------..<.>.+.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>-.++++.<.>>>.>.>>..<<<<<<.>----.++++++.<.>------.+++++++.<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>------.--.<.>++.-.<.>>>.>.>>..<<<<<<.>+.+.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>-.++++.<.>----.+++++.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>----.---.<.>>>.>.>>..<<<<<<.>+++.-.<.>+..<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>.++.<.>--.+++.<.>>>.>.>>..<<<<<<.>---.+++++.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>----.---.<.>+++.--.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>++.+.<.>>>.>.>>..<<<<<<.>-.+++.<.>---.++++.<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>---.-----.<.>+++++.----.<.>>>.>.>>..<<<<<<.>++++.--.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>++.+.<.>-.++.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>-.------.<.>>>.>.>>..<<<<<<.>++++++.----.<.>++++.---.<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>+++.-.<.>+..<.>>>.>.>>..<<<<<<.>.++.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>-.------.<.>++++++.-----.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.>+++++.--.<.>>>.>.>>..<<<<<<.>++..<.>.+.<.>>>.>.>>..<<<<.>>>.>..<<<<<<.>.--------.<.>++++++++.-------.<.>>>.>.>>..<<<<<<.>+++++++.-----.<.>>.>>>.>..<<<<<<.>>>.>.>>..<<<<<<.>+++++.--.<.>++.-.<.>>>.>.>>..<<<<<<.>>.>>>.>..<<<<<<.  • Nice solution! I could get to 425 bytes by manually writing the brainfuck code. – Forcent Vintier Dec 27 '16 at 13:04 # Rotor, 32 31 bytes 1N2{3%!"Fizz"~5%!"Buzz"N$?~N}\


This has one unprintable, so here's a hexdump:

0000000: 314e 7f32 7b33 2521 2246 697a 7a22 7e35  1N.2{3%!"Fizz"~5
0000010: 2521 2242 757a 7a22 4e24 3f7e 4e7d 5c    %!"Buzz"N$?~N}\  Explanation: 1 Push a one to the stack. N Push a newline. ^? Spooky invisible unprintable that pushes 100 to the stack. 2 Pushes a two to the stack. { Starts block. 3% Takes mod 3 of the top number on the stack. !"Fizz" If falsy, push "Fizz". ~ Push the contents of the register. 5% Takes mod 5. !"Buzz" If falsy, push "Buzz". N$      Compares the top value of the stack to a newline. (this doesn't pop the values off the stack)
?~      If truthy, push the contents of the register.
N       Push a newline.
}\ For loop between 2 and 100, pushing the counter to the register and stack each time.


Try it online. (note that it is very slow)

Check out Rotor.

# Japt, 4544433936353332 31 bytes

Japt is a shortened version of JavaScript.

Lò1@"Fizz"pXv3)+"Buzz"pXv5)ªXÃ·


Try it online!

### How it works

Lò1@"Fizz"pXv3)+"Buzz"pXv5)ª XÃ ·
Lò1@"Fizz"pXv3)+"Buzz"pXv5)||X} qR

Lò1       // Create the inclusive array [1...100].
@         // Map each item X in this range to:
"Fizz"p  //  "Fizz" repeated:
Xv3)    //   if X is divisible by 3, 1 time, otherwise, 0 times;
+        //  concatenated with
"Buzz"p  //  "Buzz" repeated:
Xv5)    //   if X is divisible by 5, 1 time, otherwise, 0 times.
||X      //  If the result is an empty string, set it to X.
} qR      // Join the range with newlines.
// Implicit: output last expression


Old version, 32 bytes:

Lo@"FizzBuzz"s°X%3©4X%5?4:8 ªXÃ·
Lo@"FizzBuzz"s++X%3&&4X%5?4:8 ||X} qR

Lo            // Create the range [0..100).
@             // Map each item X in this array to:
"FizzBuzz"s  //  "FizzBuzz".slice(
++X%3&&4    //   if ++X is divisible by 3, 0; else, 4,
X%5?4:8     //   if X is divisible by 5, 8; else, 4).
||X          //  If the result is an empty string, set it to X.
} qR          // Join the range with newlines.
// Implicit: output last expression


Alternate version (45 44 40 38 bytes): (Note: this doesn't work in the current version of Japt)

1o#e £(X%3?":Fizz" +(X%5?":Buzz" ªX} ·
1o#e m@(X%3?":Fizz" +(X%5?":Buzz" ||X} qR

1o#e          // Create an array of 1 to 100.
m@            // Map each item X in this array to:
(X%3?":Fizz" //  If X is divisible by 3, "Fizz"; else, an empty string
+            //  concatenated to:
(X%5?":Buzz" //  if X is divisible by 5, "Buzz"; else, an empty string.
||X          //  If the result is an empty string, set it to X.
} qR          // Join the range with newlines.
// Implicit: output last expression


Suggestions welcome!

# Python 2, 61 60 bytes

for i in range(1,101):print"Fizz"*(i%3<1)+"Buzz"*(i%5<1)or i

• This is invalid: it prints 0 at the start – Beta Decay Sep 24 '15 at 19:38
• You could use either i+1 or range(1,101) to fix it. – ASCIIThenANSI Sep 24 '15 at 19:40
• Now it only goes up to 99. – Zach Gates Sep 24 '15 at 19:48
• the output is also straight up incorrect. 89 prints out a FizzBuzz whereas 90 is printed as 90 – Kevin W. Sep 24 '15 at 19:50
• Have you actually tested this program? – Beta Decay Sep 24 '15 at 19:57

# Common Lisp, 1031019693 84 bytes

(dotimes(i 101)(format t"~v^~[Fizz~[Buzz~]~:;~[Buzz~:;~a~]~]
"i(mod i 3)(mod i 5)i))


Try it online!

It's shorter than other CL solution and it uses different method. Conditions are handled inside format function.

-5 bytes - shorter version of handling i=0

-3 bytes - ~^ with only one parameter seems to work as if second parameter was 0, which is saves 2 bytes. Last byte is saved by substituting ~% by <enter>

-9 bytes - by ASCII-only

• You can use ~[ instead of ~:[ and remove the (= ... 0) to reduce it to 84 bytes (with a bit of rearrangement). (not posting link because it would spoiler current code-golf.io best) – ASCII-only May 16 '18 at 9:26
• @ASCII-only Thank you for suggestion but it seems unobvious, how to do it. Without (=(mod i 5)0) I seem to need to handle residues of 1,2,3,4 separately (and similiarily for (=(mod i 3)0): 1 and 2). – PrzemysławP May 24 '18 at 20:08
• No... just use ~:; to add a default fallback: (dotimes(i 101)(format t"~v^~[Fizz~[Buzz~]~:;~[Buzz~:;~a~]~]<newline>"i(mod i 3)(mod i 5)i)) where <newline> is replaced with literal newline – ASCII-only May 24 '18 at 23:33
• @ASCII-only Thank you, I edited the answer. – PrzemysławP May 25 '18 at 16:28

# BuzzFizz, 86 bytes

$a++ if3$$\a:print"Fizz" if5\$$a:print"Buzz" else:print$a
print"\n"

# If $a is *not* divisible by 100, we have another iteration. So loop # back to the start of the program. else: loop  ## Discussion In addition to the commands seen in the FizzBuzz program above, BuzzFizz also supports input (if you use an identifier like a with no leading $, the program will ask for its value; you can use a statement like clear a to reset the value so that the program asks for it again the next time it's used). Other than that, the above program shows off all the features of the language; in other words, we have a complete language built entirely out of the operations you need to write a simple FizzBuzz program (thus the name).

Despite its inspiration, BuzzFizz is not specialised merely for FizzBuzzes; you can take the FizzBuzz program apart, put it together in other ways, and solve a surprisingly large range of problems. For example, the Esolang page for the language has a primality tester and a program which adds two positive numbers. (The primality tester is simpler than the addition program; given BuzzFizz's choice of operator, this probably shouldn't be too surprising.)

That said, the language is (intentionally) not Turing-complete; the original inspiration of the language was to act as a counterexample to people who made claims of the form "any language that can do X must be Turing-complete", as the most common choices of X don't actually require it. On the other hand, it's also (intentionally) very powerful for a sub-Turing language; it's fairly hard to come up with simple problems that BuzzFizz can't solve and Turing-complete languages can.

# Befunge-93, 82 81 bytes

I'm sure this could be golfed, but I think this is a good start.

1+:::3%:#v_"zziF"v>*|>25*,:"!"3*#@_
v _v#:%5\<   ,,,,<^ >^
<  >\"zzuB",,,,   ^ .#


Try it in this online interpreter.

## Attempts that didn't work

1+:::3%: #v_"zziF" v>*#v_>25*,:"!"3*#@_
v _v#:%5\ <>#,,,,,#<^  >.^
<  >\"zzuB"^        ^


Tries to combine the printing of Fizz and Buzz. Ends up at 88 bytes.

Vertical rendition of the above

Forgot about newlines. 122 bytes. Ick. Without newlines it would be 122-41=81 bytes. Welp.

# SQL (PostgreSQL flavour), 107 bytes

SELECT(array[n||'','Fizz','Buzz','FizzBuzz'])[1+(n%3=0)::int+(n%5=0)::int*2]FROM generate_series(1,100)a(n)


Same sort of logic as my R answer

# bc, 83 bytes

Undeclared variables are zero by default, so i=0 can be omitted. The three line breaks are required.

for(;++i<101;){if(!i%15)"FizzBuzz
"else if(!i%5)"Buzz
"else if(!i%3)"Fizz
"else i;}


# JavaScript, 79 bytes

After a long time I tried to use JS again...

for(i=0,s="";i++<100;s+=(i%5?i%3?i:'Fizz':i%3?'Buzz':'FizzBuzz')+"\n");alert(s)


Old solution, 87 bytes:

for(i=2,s="1";i<101;s+="\n"+["FizzBuzz","Buzz","Fizz",i][(i%3>0)+2*(i++%5>0)]);alert(s)

• I recommend dropping the semi-colon at the end. Also I just used conditionals i%5?i%3?i:'Fizz':i%3?'Buzz':'FizzBuzz' and I got 79 bytes, so I recommend trying that. I would also avoid s="1" and just start i=1,s="" to save an extra byte – ShadowCat7 Sep 24 '15 at 20:44
• I was working on a ?: solution but I was not able to get it to work before you commented=) Thank you very much! (Honestly I am still proud of my array indexing solution=P) – flawr Sep 24 '15 at 20:50
• A trailing newline is acceptable, but a leading newline is not. I don't like this rule, but it's a rule nevertheless – edc65 Sep 24 '15 at 21:16
• 77: change starting part i=s="". 76 using ES6 and template string for newline – edc65 Sep 24 '15 at 21:42
• 75: i recomment this for(i=0,s="";i++<100;s+=((i%3?'':'Fizz')+(i%5?'':'Buzz')||i)+"\n");alert(s), because it saves 6 – Nina Scholz Sep 29 '15 at 12:00

main=mapM(putStrLn.f)[1..100]
a%b=aremb<1
f n|n%15="FizzBuzz"|n%3="Fizz"|n%5="Buzz"
f n=show n


• first line could be main=mapM(print . f)[1..100] – man on laptop Sep 25 '15 at 11:34
• You can write all the guards of f in a single line: f n|n%15="FizzBuzz"|n%3="Fizz"|n%5="Buzz". – nimi Sep 25 '15 at 15:21
• I count 96 bytes. If you write f 3++f 5 instead of "FizzBuzz", you can save two more. Also, henkma on anarchy golf has 82 somehow. – Lynn Sep 26 '15 at 22:12
• I posted an 85 byte answer. – Lynn Sep 27 '15 at 14:45

# Fortran, 213 bytes

character(len=8)::o
do i=1,100
if(mod(i,15)==0)then;write(*,*)'FizzBuzz'
elseif(mod(i,3)==0)then;write(*,*)'Fizz'
elseif(mod(i,5)==0)then;write(*,*)'Buzz'
endif;enddo;end


Not as graceful as the golf languages. I could save bytes using print instead of write, but print indents 1 space without a format specifier which would increase the byte count instead. Likewise I lose bytes printing the number because Fortran doesn't like left-justified output for numbers. I didn't bother sticking it all on one line as newlines and semicolons are both 1 byte -- no savings.

# Bash + coreutils, 41 bytes

seq 100|sed 5~5cBuzz|sed 3~3s/[^B]*/Fizz/


You can't seem to do better without cheating: the 12-byte answers on that server simply invoke its gs2 interpreter with a 1-byte FizzBuzz program...

# GolfScript, 37 bytes

100,{)..3%!'Fizz'*\5%!'Buzz'*+\or n}/


## Groovy, 69 Bytes

(1..100).each{i->println i%15?(i%5?(i%3?i:'Fizz'):'Buzz'):'FizzBuzz'}

• Can save 2 bytes using 1.upto(100){} and no parenthesis are needed in your answer, resulting in: 1.upto(100){i->println i%15?i%5?i%3?i:'Fizz':'Buzz':'FizzBuzz'}​ +1 though :). – Magic Octopus Urn Oct 13 '16 at 17:49

# Transact-SQL, 163143124 110 bytes

This requires SQL Server 2012+

(thanks MickyT for the unnamed variable and the IIF suggestions, changed to muqo's GOTO loop instead of WHILE)

declare @ int=1a:print iif(@%3*@%5>0,ltrim(@),iif(@%3=0,'Fizz','')+iif(@%5=0,'Buzz',''))set @+=1IF @<101GOTO a


Formatted and explained:

declare @ int=1                      --@ is a valid variable name
a:                                   --shorter than WHILE
print iif(@%3*@%5>0, ltrim(@),   --ltrim is shorter than explicit cast
iif(@%3=0,'Fizz','')       --nest the IIFs
+ iif(@%5=0,'Buzz',''))
set @+=1
IF @<101 GOTO a

• Hello, and welcome to PPCG! Great answer! Can you please add an explanation? – NoOneIsHere May 6 '16 at 2:06
• Sure thing I'll include the ungolfed version, it's just a while loop – Phrancis May 6 '16 at 2:06
• I feel a bit privileged that in many languages you can't use expressions in case statements, but also a bit sad that the Oracle SQL person got fewer bytes... – Phrancis May 6 '16 at 6:15
• Good work, but this needs more golfing. Use GOTO, not WHILE. Skip CONCAT because you need to force only @ to be a string, so just enclose it in LTRIM or something. Use + for the Fizz and Buzz IIFs, and nest that in the IIF for the other numbers. Remove as many spaces as possible. I can get your entry down to 110 doing all that. – Muqo Jul 21 '16 at 13:59
• Code and explanation didn't match. Took the opportunity to edit in @Muqo's suggestions. – BradC Apr 19 '18 at 17:32