# 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.

• 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. – Reinstate Monica -- notmaynard Sep 25 '15 at 15:12

# Hexagony, 91 bytes

Thanks for the bounty :)

Wow, I would never have imagined I could beat Martin’s Hexagony solution. But—who would have thunk it—I got it done. After several days of failure because I neither had the Hexagony colorer nor the EsotericIDE to check my solution. I got several aspects of the specification wrong, so I produced a few wrong “solutions” just using pen and paper and a text editor. Well, finally I overcame my laziness and cloned both repositories, downloaded VisualStudio and compiled them. Wow, what useful tools they are! As you can see, I am far from being someone you’d call a programmer (I mean, come on! I didn’t even have VisualStudio installed, and have pretty much no clue about how to compile a program) ;)

It still took me a while to find a working solution, and it is quite crammed and chaotic, but here it is in all its glory:

Fizzbuzz in a size 6 hexagon:

3}1"$.!$>)}g4_.{$'))\<$\.\.@\}F$/;z;u;<%<_>_..>B/<>}))'%<>{>;e"-</_%;\/{}/>.\;.z;i;..>(('  Hexagonal layout:  3 } 1 "  . !  > ) } g 4 _ . {  ' ) ) \ <  \ . \ . @ \ } F \  / ; z ; u ; < % < _ > _ . .  > B / < > } ) ) ' % < > { > ; e " - < / _ % ; \ / { } / > . \ ; . z ; i ; . . > ( ( '  And the beautiful rendition, thanks to Timwi’s Hexagony Colorer: So, here is a 110 seconds long GIF animation at 2 fps, showing the program flow during the first 6 numbers 1, 2, Fizz, 4, Buzz, Fizz, the first 220 ticks of the program (click on the image for the full size): My goodness, thanks to the Natron compositing software the animation of the pointer was still tedious to create, but manageable. Saving 260 images of the memory was less amusing. Unfortunately EsotericIDE can’t do that automatically. Anyways, enjoy the animation! After all, once you wrap your head around the memory model and the rather counterintuitive wrapping of paths that cross the borders of the hexagon, Hexagony is not that hard to work with. But golfing it can be a pain in the butt. ;) It was fun! • Very nice! :) That's what I get for forgetting to try side-length 6 myself. ;) (Would be interesting to see if my solution fits into side-length 6 more easily though.) – Martin Ender Mar 6 '16 at 9:45 • @MartinBüttner I would love to see it :) – M L Mar 6 '16 at 16:56 • I am less of a programmer than you, because what is Visual Studio? :P – Rɪᴋᴇʀ Mar 10 '16 at 2:42 • Unfortunately EsotericIDE can’t do that automatically. — Please go right ahead and file a feature suggestion, I might get around to doing that some day :) – Timwi Mar 10 '16 at 13:22 • (oops this comes up after 6 months of last reply) You may golf off 1 byte from the end of the program by shifting the grey path by 1 byte and placing a "Cancelling op" in the orange path like 3}1".!>)}g4_'{))}\<\.\.@\;F$/;z;u;<%<_>_..$>B/<>}))'%<>{>;e"-</_%;\/{}/>.\)(z;i;..>('.Now there is an extra ( after the z, which can be "cancelled" with a ) or by putting the z there. Now it is a ) which pushes all commands on the orange path 1 tick later, and got back with the no-op that was on line 3. Btw I also installed Visual Studio just due to Hexagony Colorer and Esoteric IDE :P – Sunny Pun Oct 14 '16 at 3:50 # Python 2, 56 bytes i=0;exec"print i%3/2*'Fizz'+i%5/4*'Buzz'or-~i;i+=1;"*100  Try it online! • Dang, that's bloody genius. Can I steal your idea to multiply the string by the mod-result? – AdmBorkBork Sep 24 '15 at 20:01 • @TimmyD Go ahead. – feersum Sep 24 '15 at 20:06 • A different method for 56 (from here): i=1;exec"print'FizzBuzz'[i%-3&4:12&8-i%5]or i;i+=1;"*100. Anyone want to brute force search expressions to try to optimize the bit bashing? – xnor Sep 25 '15 at 5:35 • Very nice technique, I love the division of the modulo result to make it binary! I have an improvement to get your method down to 54 chars... Of course I wouldn't post it as an answer without your permission (since it's ~95% your answer) ;) – Tersosauros Mar 6 '16 at 13:09 • @Tersosauros Go ahead... my method is not very hard to find and has no doubt been independently discovered by many people. – feersum Mar 6 '16 at 21:16 # Labyrinth, 94 bytes "):_1 \ } 01/3%70.105 " : @ " . " =";_""..:221 + _ "! 5%66.117 _:= " . ="*{"..:221  Sub-100! This was a fun one. ## Explanation Let's start with a brief primer on Labyrinth – feel free to skip this if you're already familiar with the basics: • Labyrinth has two stacks – a main stack and an auxiliary stack. Both stacks have an infinite number of zeroes at the bottom, e.g. + on an empty stack adds two zeroes, thus pushing zero. • Control flow in Labyrinth is decided by junctions, which look at the top of the stack to determine where to go next. Negative means turn left, zero means go straight ahead and positive means turn right... but if we hit a wall then we reverse direction. For example, if only straight ahead and turn left are possible but the top of the stack is positive, then since we can't turn right we turn left instead. • Digits in Labyrinth pop x and push 10*x + <digit>, which makes it easy to build up large numbers. However, this means that we need an instruction to push 0 in order to start a new number, which is _ in Labyrinth. Now let's get to the actual code! ### Red Execution starts from the " in the top-left corner, which is a NOP. Next is ), which increments the top of the stack, pushing 1 on the first pass and incrementing n on every following pass. Next we duplicate n with :. Since n is positive, we turn right, executing } (shift top of main stack to auxiliary) and :. We hit a dead end, so we turn around and execute } and : once more, leaving the stacks like Main [ n n | n n ] Aux  Once again, n is positive and we turn right, executing _101/ which divides n by 101. If n is 101 then n/101 = 1 and we turn into the @, which terminates the program. Otherwise, our current situation is Main [ n 0 | n n ] Aux  ### Orange 1 (mod 3) 3 turns the top zero into a 3 (10*0 + 3 = 3) and % performs a modulo. If n%3 is positive, we turn right into the yellow ". Otherwise we perform 70.105.122:.., which outputs Fizz. Note that we don't need to push new zeroes with _ since n%3 was zero in this case, so we can exploit the infinite zeroes at the bottom of the stack. Both paths meet up again at light blue. ### Light blue The top of the stack is currently n%3, which could be positive, so the _; just pushes a zero and immediately pops it to make sure we go straight ahead, instead of turning into the @. We then use = to swap the tops of the main and auxiliary stacks, giving: Main [ n | n%3 n ] Aux  ### Orange 2 (mod 5) This is a similar situation to before, except that 66.117.122:.. outputs Buzz if n%5 is zero. ### Dark blue The previous section leaves the stacks like Main [ n%5 | n%3 n ] Aux  { shifts the n%3 back to the main stack and * multiplies the two modulos. If either modulo is zero, the product is zero so we go straight into yellow. = swaps the top of the stacks and _ pushes a zero to make sure we go straight ahead, giving Main [ n 0 | 0 ] Aux  Otherwise, if both modulos are nonzero, then the product is nonzero and we turn right into green. = swaps the tops of the stacks, giving Main [ n | (n%5)*(n%3) ] Aux  after which we use : to duplicate n, turn right, then use ! to output n. ### Purple At this point, the main stack has either one or two items, depending on which path was taken. We need to get rid of the zero from the yellow path, and to do that we use +, which performs n + 0 in some order for both cases. Finally, \ outputs a newline and we're back at the start. Each iteration pushes an extra (n%5)*(n%3) to the auxiliary stack, but otherwise we do the same thing all over again. • Loving the explanation. – The_Basset_Hound Sep 27 '15 at 23:08 # Perl 5, 49 bytes 46 bytes script + 3 bytes -E"..." Using say (which requires -E"...") can reduce this further to 46 bytes since say automatically includes a newline (Thanks @Dennis!): say'Fizz'x!($_%3).Buzz x!($_%5)||$_ for 1..100


# Perl 5, 50 bytes

print'Fizz'x!($_%3).Buzz x!($_%5)||$_,$/for 1..100

• You can save a few bytes by using say. – Dennis Sep 25 '15 at 6:15
• You broke the scoreboard... – LegionMammal978 Sep 27 '15 at 12:10
• @LegionMammal978 Yes. Yes I did... I'll try and re-word the title then! Argh! – Dom Hastings Sep 27 '15 at 12:47
• Isn't -E"..." 8 bytes? Space + Dash + Option + Argument (+ Quoting). – Erik the Outgolfer Sep 22 '16 at 11:00
• @EriktheGolfer so since I posted this, the consensus is that -E is 0 bytes, but since primo's answer was scored excluding the quotes, I opted to make it fair and include the quotes in mine and +1 for -E. The reason it's accepted as free is Perl is usually run via perl -e and perl -E is no more bytes (I thought -M5.010 or use 5.010 can be free as well, but perhaps not re-reading the meta post). When adding -p or -n this is counted as +1 as you would run with perl -pe. Hope that helps! Meta reference: meta.codegolf.stackexchange.com/a/7539 – Dom Hastings Sep 22 '16 at 11:30

# Ruby, 50 bytes

Requires version 1.8, which seems to be popular among golfers:

1.upto(?d){|n|puts'FizzBuzz
'[i=n**4%-15,i+13]||n}


In modern Ruby, you replace ?d with 100 for a 51-byte solution.

This seems to be the world record.

• That is diabolical, love it. – Camden Narzt Sep 28 '15 at 1:13
• ?d is just 100. The FizzBuzz string has a newline in it, this is valid in Ruby. string[i, s] is a slice, starting at character i (0-indexed), going on for s characters, ignoring indices pointing outside the string. If the argument to puts already has a newline, it is chopped off. The formula should be simple to read? It does all the work here. I wouldn't've found it without the help of some really pro Ruby golfers. – Lynn Sep 30 '15 at 21:34
• side note: if you were allowed to add 0 at the beginning of input(you're not), 2 bytes could be saved by using ?e.times instead. – Shelvacu Nov 12 '15 at 6:11
• @Piccolo Does this snippet help? If i==-14 the slice is out of bounds so we get nil. If i==-9 we slice i+13==4 characters starting from the 9th character from the end, so 'Fizz'. If i==-5 we slice 8 characters starting from the 5th character from the end, so 'Buzz\n'. (We try to slice 8 but there are only 5, so we get 5.) Et cetera. – Lynn Aug 4 '18 at 23:15
• With Ruby 2.7, a 50-character solution is once again possible: 1.upto(100){puts'FizzBuzz\n'[n=_1**4%-15,n+13]||_1} – Nnnes Mar 3 '20 at 18:29

# gs2, 1

f


A quote from Mauris, the creator of gs2:

I wanted to one-up goruby's 1-byte Hello, world!, so... This prints "1\n2\nFizz\n4\nBuzz\n...". :)

Update: Added 27-byte answer that doesn't use f.

# Java, 130 bytes

This is for recent Java versions (7+). In older ones you can shave some more off using the enum trick, but I don't think the logic gets any shorter than this (86 inside main).

class F{public static void main(String[]a){for(int i=0;i++<100;)System.out.println((i%3<1?"Fizz":"")+(i%5<1?"Buzz":i%3<1?"":i));}}

• I don't think the initializer block trick helps here, since the question specifies empty stderr. – feersum Sep 24 '15 at 19:47
• beat me by 14 bytes! Using <1 instead of ==0 is a great way to save! – ESP Nov 8 '15 at 18:25
• class F{public static -> interface F{static in java 8 – TheNumberOne Nov 28 '15 at 15:53
• That's not quite how enums work. You would have to do enum F{;public..., so you wouldn't actually be saving any bytes. – hyper-neutrino Mar 7 '16 at 2:56
• @HyperNeutrino The enum trick works if you add System.exit(0); at the end. Total length: 112 bytes. enum F{F;{for(int i=0;i++<100;)System.out.println((i%3<1?"Fizz":"")+(i%5<1?"Buzz":i%3<1?"":i));System.exit(0);}}. See my "Hello World" answer for details. – Olivier Grégoire Nov 23 '17 at 17:48

# Pyth, 30

VS100|+*!%N3"Fizz"*!%N5"Buzz"N


Try it here

### Explanation:

VS100|+*!%N3"Fizz"*!%N5"Buzz"N
VS100                            : for N in range(1,101)
|                           : logical short-circuiting or
+*!%N3"Fizz"               : add "Fizz" * not(N % 3)
: Since not gives True/False this is either "" or "Fizz"
*!%N5"Buzz"    : Same but with 5 and Buzz
N   : Otherwise N
: The output of the | is implicitly printed with a newline


## Retina, 317139134132706360 55 bytes

.100{^
_
*\(a(___)+
Fi;$& \b(_{5})+$
Bu;
;_*
zz
'_&.


Try it online!

## Explanation

.100{^
_


The . is the global silent flag which turns off implicit output at the end of the program. 100{ wraps the rest of the program in a loop which is executed for 100 iterations. Finally, the stage itself just inserts a _ at the beginning of the string, which effectively increments a unary loop counter.

*\(a(___)+
Fi;$&  More configuration. *\( wraps the remainder of the program in a group, prints its result with a trailing linefeed, but also puts the entire group in a dry run, which means that its result will be discarded after printing, so that our loop counter isn't actually modified. a is a custom regex modifier which anchors the regex to the entire string (which saves a byte on using ^ and $ explicitly).

The atomic stage itself takes care of Fizz. Divisibility by 3 can easily be checked in unary: just test if the number can be written as a repetition of ___. If this is the case, we prepend Fi; to the string. The semicolon is so that there is still a word boundary in front of the number for the next stage. If we turned the line into Fizz___... the position between z and _ would not be considered a boundary, because regex treats both letters and underscores as word characters. However, the semicolon also allows us to remove the zz duplication from Fizz and Buzz.

\b(_{5})+$Bu;  We do the exact same for divisibility by 5 and Bu;, although we don't need to keep the _s around this time. So we would get a results like _ __ Fi;___ ____ Bu; Fi;______ ... Fi;Bu; ...  This makes it very easy to get rid of the underscores only in those lines which contain Fizz, while also filling in the zzs: ;_* zz  That is, we turn each semicolon into zz but we also consume all the _s right after it. At this point we're done with FizzBuzz in unary. But the challenge wants decimal output. '_&.  & indicates a conditional: this stage is only executed if the string contains an underscore. Therefore, Fizz, Buzz and FizzBuzz iterations are left untouched. In all other iterations (i.e. those which are neither divisible by 3 nor 5), we just count the number of characters, converting the result to decimal. # JavaScript, 62 bytes for(i=0;++i<101;console.log(i%5?f||i:f+'Buzz'))f=i%3?'':'Fizz'  I think I this is the shortest Javascript solution now. • Wow, just wow! But all the other JS answers use console.log; it's much less annoying than having to press "OK" on 100 pop-up boxes in a row. Could you please change this? It'll only be 62 bytes, still three better than mine. – ETHproductions Nov 15 '15 at 3:04 • I'll have to do so tomorrow, as I have already edited 5 of my own posts and can't edit anymore... – Mama Fun Roll Nov 15 '15 at 5:16 • Oh, I didn't realise there was a limit to editing... – ETHproductions Nov 15 '15 at 18:48 • So if I found a shorter answer that's similar to this, do I edit this or post a new answer? (it still uses console.log) – Samathingamajig Oct 26 '20 at 2:44 # beeswax, 10489 81 bytes Denser packing allowed for cutting off 8 more bytes. Shortest solution (81 bytes), same program flow, different packing. p?@< p?{@b'gA< p@zzuBd'%~5F@<fz< >~P"#"_"1F3~%'dFizb d;"-~@~.< >?N@9P~0+d  Changing the concept enabled me to cut down the code by 15 bytes. I wanted to get rid of the double mod 5 test in the solution, so I implemented a flag. Short explanation: if n%3=0 Fizz gets printed, and the flag gets set. The flag is realized simply by pushing the top lstack value onto the gstack (instruction f). If n%5=0, then either n%3=0(FizzBuzz case) or n%3>0(Buzz case). In both cases, Buzz gets printed, and the flag reset by popping the stack until it’s empty (instruction ?). Now the interesting cases: If n%5>0, then either we had n%3=0 (printing Fizz case, n must not be printed) or n%3>0 (Fizz was not printed, so n has to be printed). Time to check the flag. This is realized by pushing the length of gstack on top of gstack (instruction A). If n%3 was 0 then the gstack length is >0. If n%3 was >0, the gstack length is 0. A simple conditional jump makes sure n gets only printed if the length of gstack was 0. Again, after printing any of n, Fizz, and/or Buzz and the newline, the gstack gets popped twice to make sure it’s empty. gstack is either empty [], which leads to [0] after instruction A (push length of gstack on gstack), or it contains one zero ([0],the result of n%3), which leads to [0 1], as [0] has the length 1. Popping from an empty stack does not change the stack, so it’s safe to pop twice. If you look closer you can see that, in principle, I folded > q dFizzf>  into <fz< dFizb  which helps to get rid of the all the wasted space between A and < at the end of the following row in the older solution below: q?{@b'gA< p <  New concept solution (89 bytes) including animated explanation: q?@ < q?{@b'gA< p < p?<@zzuBb'%~5F@<fzziFb'< >N@9P~0+.~@~-";~P"#"_"1F3~%d  Hexagonal layout:  q ? @ < q ? { @ b ' g A < p < p ? < @  z z u B  b ' % ~ 5 F @ < f  z z i F  b ' < > N @ 9 P ~ 0 + . ~ @ ~ - " ; ~ P " # " _ " 1 F 3 ~ % d  Animation of the first 326 ticks at 2 fps, with local and global stacks, and output to STDOUT. For comparison, below are the path overlays of the older, more complex solution. Maybe it’s also the prettier solution, from a visual standpoint ;) • This is as crazy and beautiful as Hexagony. Have a +1! – ETHproductions Feb 26 '16 at 17:08 • @ETHproductions I still need to give Hexagony a try, but from what I can tell from the language specs, my beeswax doesn’t even come close to the craziness of Hexagony. – M L Feb 26 '16 at 17:17 • – M L Dec 3 '16 at 20:53 • How are you making those animations? – baordog Aug 19 '18 at 3:32 # Perl 5, 45 bytes say((Fizz)[$_%3].(Buzz)[$_%5]or$_)for+1..100


Requires the -E option, counted as one. This must be run from the command line, i.e.:

perl -Esay((Fizz)[$_%3].(Buzz)[$_%5]or$_)for+1..100  Quotes around the command are unnecessary, if one avoids using spaces, or any other characters which can act as command line separators (|, <, >, &, etc.). # Perl 5, 48 bytes print+(Fizz)[$_%3].(Buzz)[$_%5]||$_,$/for 1..100  If command line options are counted as one each, -l would save one byte (by replacing $/). By Classic Perlgolf Rules, however, this would count 3: one for the -, one for the l, and one for the necessary space.

• You can use say, with the -E switch, which has edit distance 1 to -e, so it should count as 1 byte. – Dennis Sep 25 '15 at 6:24
• Hey primo, I feel like I'm cheating in my answer for using say, I've assumed that -E can be used in place of -e which would bring you down to 44 rather than 46. I don't think it's fair that I'm scoring differently to you, what's the preferred scoring mechanism? I generally use print to avoid this! Closest to a consensus would be this? – Dom Hastings Sep 25 '15 at 16:15
• My personal take is that every additional byte on the command line should score 1. In particular for say, if your code can be written on one line avoiding any OS separators, score 1 for -E. If you need to use quotes, e.g. -E"$a||$b", score 3. If you can't get it on one line, score 5 for -M5.01. But at that point you'd probably be better off using -l. I don't agree that it should be free by default, for two reasons: 1) the improvement is trivial and uninteresting, and 2) there is no version of the interpreter for which it is enabled by default. – primo Sep 25 '15 at 16:39

# gs2, 28 27 (without f)

Hex:

1b 2f fe cc 04 46 69 7a 7a 09 07 42 75 7a 7a 19 06 27 2d d8 62 32 ec 99 dc 61 0a


Explanation:

1b    100
2f    range1 (1..n)
fe    m: (map rest of program)

cc    put0 (pop and store in register 0)
04    string-begin
Fizz
09    9
07    string-separator
Buzz
19    25
06    string-end-array (result: ["Fizz"+chr(9) "Buzz"+chr(25)])

27    right-uncons
2d    sqrt
d8    tuck0 (insert value of register 0 under top of stack)
62    divides
32    times (string multiplication)
ec    m5 (create block from previous 5 tokens, then call map)

99    flatten
dc    show0 (convert register 0 to string and push it)
61    logical-or
0a    newline


Embedding 3 and 5 into the string constant doesn't work because \x05 ends string literals.

Note: This problem can be solved in 1 byte with gs2 using the built-in f.

## 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

# ><>, 686665 64 bytes

1\2+2foooo "Buzz"<

# MUMPS, 56 54 bytes

f i=1:1:100 w:i#5=0 "Fizz" w:i#3=0 "Buzz" w:$X<3 i w !  What's this w:$X<3 i thing, you ask? $X is a magic variable (an "intrinsic") that stores the horizontal position of the output cursor (as a number of characters from the left edge of the terminal). w is the abbreviated form of the WRITE command. The syntax command:condition args is a postconditional - "if condition, then do command args". So we're checking whether the output cursor has been advanced more than two characters (which would mean that at least one of "Fizz" or "Buzz" has been written to the terminal), and if not, writing i to the terminal. The $X variable - and hence, this sort of deep inseparability from the terminal - is a first-class feature of MUMPS. Yikes.

# Scratch, 203 185 bytes

Bytes counted from the golfed textual representation, per this meta post. Scratch is not very space-efficient.

say is the closest thing to a stdout Scratch has: the sprite displays a speech bubble containing whatever it is saying. In practice, a wait n secs block would be needed to actually read this output, but for the purposes of this challenge this code fulfills the requirements.

• You're missing numbers after the y = (in both occurrences) – Beta Decay Oct 28 '15 at 10:29
• @BetaDecay Sorry? I don't follow. – Tuesday Oct 28 '15 at 14:33
• @BetaDecay That's the empty string. :) if you click on the image, you can view it in action! – Tuesday Oct 28 '15 at 17:12
• Nice one. I've never seen a Scratch solution before. :) – hyper-neutrino Mar 7 '16 at 3:01
• Never thought Scratch solution will show up here. So awesome to see this. Great work @timothymh – Joe Ferndz Dec 26 '20 at 5:50

# Haskell, 84 82 bytes

main=mapM putStrLn[show nmaxmap("FizzBuzz"!!)[6-2*gcd 3n..2+gcd 5n]|n<-[1..100]]


The expressions work out like this:

 n   6-2*gcd(3,n)  2+gcd(5,n)
=============================
1        4             3
2        4             3
3       *0             3
4        4             3
5        4            *7
6       *0             3
7        4             3
8        4             3
9       *0             3
10        4            *7
11        4             3
12       *0             3
13        4             3
14        4             3
15       *0            *7
16       ...           ...


We use them as start and end points for slicing the string. For example, when n == 5, then map("FizzBuzz"!!)[4..7] == "Buzz".

For non-divisible numbers, the range [4..3] is empty, so the result of map is "", and max (show n) replaces that result.

## Old 84 byte answer

main=mapM f[1..100]
f n|d<-drop.(*4).mod n=putStrLn$max(show n)$d 3"Fizz"++d 5"Buzz"


d = drop.(*4).mod n is key here: d 3 "Fizz" is drop (nmod3 * 4) "Fizz". This is "Fizz" when n mod 3 is 0 and "" otherwise.

## Other stuff

I got here via this 85:

main=mapM putStrLn[max(show n)$drop(6-2*gcd 3n)$take(3+gcd 5n)"FizzBuzz"|n<-[1..100]]


Here is another interesting 85:

f n=cycle[show n,"Fizz","Buzz",f 3++f 5]!!div(gcd 15n)2
main=mapM(putStrLn.f)[1..100]


The world record is 80 bytes by henkma.

• Rearrangement golfs it down to 82, I think: (%)=drop.(*4).mod n;main=mapM putStrLn[max(show n)$3%"Fizz"++5%"Buzz"|n<-[0..100]]. – CR Drost Sep 27 '15 at 16:35 • Wait, then n isn't in scope. Hm. – CR Drost Sep 27 '15 at 16:38 • Yeah, that doesn't work, but I've hit an alternative 85-byte solution that looks a lot like it: main=mapM putStrLn[max(show n)$3%"Fizz"++5%"Buzz"|n<-[0..100],(%)<-[drop.(*4).mod n]] – Lynn Sep 28 '15 at 22:47
• I suggest you reconsider your quest for readable code on a code golf website :) – Lynn Feb 28 '19 at 22:25
• @dfeuer I found a shorter solution, so you can fix your downvote if you'd like. – Lynn Sep 29 '20 at 22:20

# CJam, 35 bytes

100{)_[Z5]f%:!"FizzBuzz"4/.*s\e|N}/


Try it online in the CJam interpreter.

### How it works

100{)_[Z5]f%:!"FizzBuzz"4/.*s\e|N}/
100{                             }/  For each integer I between 0 and 99:
)_                                 Increment I and push a copy.
[Z5]                             Push [3 5].
f%                           Map % to push [(I+1)%3 (I+1)%5].
:!                         Apply logical NOT to each remainder.
"FizzBuzz"4/             Push ["Fizz" "Buzz"].
.*           Vectorized string repetition.
s\         Flatten the result and swap it with I+1.
e|       Logical OR; if s' pushed an empty string,
replace it with I+1.
N      Push a linefeed.

• More straightforward solution: 100{):I3%!"Fizz"*I5%!"Buzz"*+Ie|N}/ – aditsu quit because SE is EVIL Sep 30 '15 at 14:12

# C#, 128126125 124 bytes

class A{static void Main(){for(var i=0;i++<100;)System.Console.Write("{0:#}{1:;;Fizz}{2:;;Buzz}\n",i%3*i%5>0?i:0,i%3,i%5);}}


89 bytes without the boilerplate code around.

Done with the use of C#'s conditional formatting.

With two section separators ;, Fizz or Buzz are printed if the value from their condition is zero.

Saved a total of 4 bytes thanks to @RubberDuck, @Timwi and @Riokmij.

• It would be shorter to call Write and append the newline directly to the string, right? – RubberDuck Sep 24 '15 at 23:26
• It’s also one byte shorter to write i%3*i%5>0?i:0 instead of i%3*i%5==0?0:i. – Timwi Sep 24 '15 at 23:31
• You can save another byte on the for statement by using for(var i=0;i++<100;) – Najkin Sep 25 '15 at 8:08
• You can save three more bytes by leveraging String Interpolation from C#6.0 and embedding the format arguments into the string itself (e.g. $"{(i%3*i%5>0?i:0):#}...\n") – LiamK Sep 29 '15 at 12:58 • can do with 121 bytes today - class A{static void Main(){for(var i=0;i<100;)System.Console.Write($"{(++i%3*i%5<1?0:i):#}{i%3:;;Fizz}{i%5:;;Buzz}\n");}} – Jerri Kangasniemi Oct 28 '18 at 9:45

# Vyxal, j, 18171412 11 bytes

₁ƛ₍₃₅kF½*∑⟇


Try it Online!

I refuse to be beaten by Arn and Ash. I absolutely will not be beaten by either of those languages. Vyxal forever lads.

## Explained

₁ƛ₍₃₅kF½*∑⟇
₁           # Push 100 to the stack
ƛ          # Over the range [1, 100], map: (we'll call the argument n)
₍₃₅       #   [n % 3 == 0, n % 5 == 0] (call this X)
kF     #   "FizzBuzz"
½    #   ["Fizz", "Buzz"] # halve the string - split into two equal pieces
*∑  #   sum(X * ↑)
⟇ #   ↑ or n
# The -j flag joins on newlines before outputting

• Finally!! Vyxal! – null Aug 29 '20 at 5:53
• @petStorm it's implemented now – lyxal Aug 29 '20 at 7:44
• I don't think it counts as beating anyone if the language was designed after the challenge – Luis Mendo Aug 31 '20 at 12:33
• There's a debate to be had about whether it means anything for an answer to beat or be beaten by an answer in a different language, but the age of the language should be irrelevant in that determination. – pppery Sep 2 '20 at 2:59
• I see. Well... I know how meta counts flags, but I'm not sure how sportsmanlike it is to compare your language (and say you "legitimately beat Dennis") to Jelly, which has no such flags, without counting the flags. You're basically tucking an implicit "increment" and "join by NL" instruction into the program flags, and then counting two fewer bytes. – Lynn Sep 30 '20 at 13:37

# PowerShell, 786861 54 Bytes

1..100|%{(($t="Fizz"*!($_%3)+"Buzz"*!($_%5)),$_)[!$t]}  Edit: Saved 10 bytes thanks to feersum Edit2: Realized that with feersum's trick, I no longer need to formulate$t as a string-of-code-blocks

Edit3: Saved another 7 bytes thanks to Danko Durbić

Similar-ish in spirit to the stock Rosetta Code answer, but golfed down quite a bit.

### Explanation

1..100|%{...} Create a collection of 1 through 100, then for-each object in that collection, do

(...,$_) create a new collection of two elements: 0) $t=... set the variable $t equal to a string; 1) $_ our-current-number of the loop

"Fizz"*!($_%3) take our-current-number, mod it by 3, then NOT the result. Multiply "Fizz" by that, and add it to the string (and similar for 5). PowerShell treats any non-zero number as $TRUE, and thus the NOT of a non-zero number is 0, meaning that only if our-current-number is a multiple of 3 will "Fizz" get added to the string.

[!$t] indexes into the collection we just created, based on the value of the string $t -- non-empty, print it, else print our-current-number

### Alternatively, also 54 bytes

1..100|%{'Fizz'*!($_%3)+'Buzz'*!($_%5)-replace'^$',$_}


Thanks to TesselatingHeckler

Similar in concept, this uses the inline -replace operator and a regular expression to swap out an empty string ^$ with our-current-number. If the string is non-empty, it doesn't get swapped. ### Alternatively, also 54 bytes 1..100|%{($_,('Fizz'*!($_%3)+'Buzz'*!($_%5))|sort)[1]}


This is the same loop structure as above, but inside it sorts the pair (n, string), and relies on the fact that an empty string sorts before a number, but a FizzBuzz string sorts after a number. Then it indexes the second sort result.

• As an aside, if PowerShell ever implemented the || operator, like in C#, we could likely get down to 43 bytes with something similar to 1..100|%{"Fizz"*!($_%3)+"Buzz"*!($_%5)||$_} ... doubtful, since the | is such an important special operator in PowerShell, but I can dream ... – AdmBorkBork Sep 24 '15 at 20:51 • How about 1..100|%{'Fizz'*!($_%3)+'Buzz'*!($_%5)-replace'^$',$_} for 54? – TessellatingHeckler Sep 25 '15 at 6:18 • You can replace if($t){$t}else{$_} with something like ($t,$_)[!$t] – Danko Durbić Sep 25 '15 at 7:03 • ... so you get 1..100|%{(($t="Fizz"*!($_%3)+"Buzz"*!($_%5)),$_)[!$t]} which is also 54 like @TessellatingHeckler's suggestion – Danko Durbić Sep 25 '15 at 8:01
• @TessellatingHeckler PowerShell is nothing if not flexible. – AdmBorkBork Sep 26 '15 at 0:34

# Clojure, 113106101100 91 bytes

My first golf!

(dotimes[i 100](println(str({2'Fizz}(mod i 3))({4'Buzz}(mod i 5)({2""}(mod i 3)(inc i))))))


Ungolfed:

(dotimes [i 100] ; account for off-by-one later
(println (str ({2 'Fizz} ; str converts symbols to strings
(mod i 3))
({4 'Buzz} ; 4 instead of 0 because of off-by-one
(mod i 5)
({2 ""} ; shortest way to write when-not
(mod i 3)
(inc i))))))

• You can remove 5 characters by handling the println the same way as in the Java solution, eg. (doall(map #(let[t(=(mod % 3)0)](println(str(if t"Fizz""")(if(=(mod % 5)0)"Buzz"(if t""%)))))(range 1 101))) – resueman Sep 25 '15 at 14:47
• @resueman Thanks! It actually ended up being 7, because (if t"Fizz""") can be simplified to (if t"Fizz"). :) – Sam Estep Sep 25 '15 at 16:49
• +1 Nice modulo trick, at first I though you had off-by-one errors. – coredump Sep 28 '15 at 8:09

# brainfuck, 411 350 277 258 bytes

Edits:

• -61 bytes by storing the values of "Fizz Buzz" as "BuziF" "BuziG" and redoing the number printing section.

• -71 bytes by redoing the modulo number printing section, splitting the loop counter and the number counter, and reusing the newline cell as the mod value, among other things

• -19 bytes by realising that there aren't any 0s in any FizzBuzz numbers. Also added explanation

+[-[>+<<]>-]>--[>+>++>++>++++++>+>>>++++++[<<<]>-]<+++++[>+>+>->>->++>>>-->>>++[<<<]>>>-]>[>]+++>>[>+<<<-[<]<[>+++>+<<-.+<.<..[<]<]>>-[<<]>[.>.>..>>>>+[<]+++++<]>[>]>>[[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>[-<+>]>,>[>]<[>-[<+>-----]<---.,<]++++++++++>]<.<<<<,>-]

Try it online!

Instead of checking if the number itself was divisible by 5 or 3 I had two counters keeping track of the modulo of the number, decrementing them for each number and printing out the corresponding word when they reached 0.

### How It Works:

+[-[>+<<]>-]>--  Generate the number 61
[>+>++>++>++++++>+>>>++++++[<<<]>-] Set the tape to multiples of 61
TAPE: 0 0' 61  122 122 110 61  0 0 110
"=" "z" "z" "n" "="
<+++++[>+>+>->>->++>>>-->>>++[<<<]>>>-]>[>]+++>> Modify values by multiples of 5
TAPE: 0' 5 66  117 122 105 71  3 0 100' 0 0 10
"B" "u" "z" "i" "G"
Some info:
5     - Buzz counter
"Buz" - Buzz printing
"ziG" - Fizz printing. Modifying the G in the loop is shorter than modifying it outside
3     - Fizz counter
0     - This is where the Fizz|Buzz check will be located
100   - Loop counter
0     - Number counter. It's not worth it to reuse the loop counter as this.
0     - Sometimes a zero is just a zero
10    - Value as a newline and to mod the number by

[ Loop 100 times
>+<<<  Increment number counter
-[<]<  Decrement Fizz counter
[ If Fizz counter is 0
>+++ Reset the Fizz counter to 3
>+<< Set the Fizz|Buzz check to true
-.+<.<.. Print "Fizz"
[<]<] Sync pointers
>>-[<<]> Decrement Buzz counter
[ If Buzz counter is 0
.>.>.. Print "Buzz"
>>>>+  Set the Fizz|Buzz check to true
[<]+++++< Reset the Buzz counter to 5
]
>[>]>> Go to Fizz|Buzz check
[ If there was no Fizz or Buzz for this number
TAPE: 3% BuziG 5% 0 Loop Num' 0 10
[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]  Mod the number counter by 10
TAPE: 3% BuziG 5% 0 Loop 0' Num 10-Num%10 Num%10 Num/10
>[-<+>] Move Num back in place
>,>[>]< Reset 10-Num%10
[ For both Num/10 (if it exists) and Num%10
>-[<+>-----]<--- Add 48 to the number to turn it into the ASCII equivilent
.,< Print and remove
]
++++++++++> Add the 10 back
]
<. Print the newline
<<<<, Remove Fizz|Buzz check
>- Decrement Loop counter
]

• Well done Jo! I might try to beat that someday :) – Forcent Vintier Dec 15 '17 at 16:33

# 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

# 80386 machine code + DOS, 75 bytes

Hexdump of the code:

0D 0A 24 B1 64 33 C0 BA-03 05 BB 00 01 40 50 FE
CE 75 0C 83 EB 04 66 C7-07 42 75 7A 7A B6 05 FE
CA 75 0C 83 EB 04 66 C7-07 46 69 7A 7A B2 03 84
FF 74 0C D4 0A 04 30 4B-88 07 C1 E8 08 75 F4 52
8B D3 B4 09 CD 21 5A 58-E2 C0 C3


Source code (TASM syntax):

    .MODEL TINY

.CODE
.386
org 100h

MAIN PROC
db 13, 10, '$' mov cl, 100 xor ax, ax mov dx, 503h main_loop: mov bx, 100h inc ax push ax dec dh jnz short buzz_done sub bx, 4 mov dword ptr [bx], 'zzuB' mov dh, 5 buzz_done: dec dl jnz short fizz_done sub bx, 4 mov dword ptr [bx], 'zziF' mov dl, 3 fizz_done: test bh, bh jz short num_done decimal_loop: aam; add al, '0' dec bx mov [bx], al shr ax, 8 jnz decimal_loop num_done: push dx mov dx, bx; mov ah, 9 int 21h pop dx pop ax loop main_loop ret MAIN ENDP END MAIN  This code counts from 1 to 100 in ax, building the output message from the end to the beginning. The end of the message (newline and the $ character that DOS uses for end-of-message flag) appears at the beginning of the code:

db 10, 10, '\$'


It's executed as a harmless instruction (or ax, 240ah). I could put it in a more conventional place, like after the end of the code, but having it at address 0x100 has a benefit.

The code also uses 2 additional counters:

• Counting from 3 to 0 in dl
• Counting from 5 to 0 in dh

When a counter reaches 0, it pushes the string Fizz or Buzz to the end of the output message. If this happens, bx will be decreased, and bh will be zero. This is used as a condition for outputting the number in a decimal form.

Note: I am using 32-bit data here. This won't work on a pre-386 computer.

• Does TASM really handle multi-byte characters constants in the opposite order from NASM? In NASM, you write mov [mem], 'Fizz' to store Fizz in that order in memory, matching db directives. See my overcomplicated "efficient" YASM FizzBuzz for example. – Peter Cordes May 28 '16 at 0:36
• Does it save any bytes to use std, then stosb / stosd? You'd have to replace test bh,bh with cmp di, 100h or something. Instead of saving/restoring the counter in AL, you could keep it in BL and just clobber eax whenever you want. E.g. sub bx, 4 / mov dword ptr [bx], 'zzuB' is 3+7 bytes, right? mov eax, 'zzuB' / stosd is 6+2 bytes (operand-size prefix on both). It would be nice if the answer included disassembly so instruction sizes were visible. – Peter Cordes May 28 '16 at 0:46
• This is a great answer - abusing benign instructions for data and using never-used PSP memory space. @PeterCordes I played with your suggestions using stosd but wasn't able to eek out any score reduction myself. Since stosd decrements DI afterwards you don't get to lose the sub di, 4 and then you have DI 4 bytes off at the end. I was able to -6 bytes` using a few other minor tweaks which I ended up posting as a separate answer (only because I couldn't possibly fit in all a comment). Kudos! – 640KB Aug 27 '19 at 17:19