196
\$\begingroup\$

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>

\$\endgroup\$
14
  • 1
    \$\begingroup\$ Nothing can be printed to STDERR. Is this true only when running, or also when compiling (assuming that is a separate step?) \$\endgroup\$
    – AShelly
    Sep 24, 2015 at 20:47
  • 1
    \$\begingroup\$ @AShelly Only when running \$\endgroup\$
    – Beta Decay
    Sep 24, 2015 at 20:48
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Timwi
    Sep 24, 2015 at 23:28
  • 9
    \$\begingroup\$ @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. \$\endgroup\$
    – Geobits
    Sep 25, 2015 at 0:50
  • 76
    \$\begingroup\$ A "vanilla fizzbuzz" sounds delicious. \$\endgroup\$ Sep 25, 2015 at 15:12

416 Answers 416

1
4 5
6
7 8
14
3
\$\begingroup\$

Julia 1.0, 72 bytes

(n->println([n,"Fizz","Buzz","FizzBuzz"][sum(n.%[1,3,5,5].<1)])).(1:100)

Not the shortest solution possible, but I like the obfuscation. Try it online!

Explanation

We apply an anonymous function (n->...) itemwise .( ) to the range 1:100.

The function body does this (using sample input n=5):

n.%[1,3,5,5]          # Modulo n by each of these numbers                     [0,2,0,0]
.<1                   # Itemwise, is each remainder zero?                     [true,false,true,true]
sum(  )               # Count number of trues in the array                    3
                      # This will be 4 for multiples of 15, 3 for multiples
                      # of 5, 2 for multiples of 3, and 1 for other numbers
[n,"F","B","FB"][  ]  # Index (1-based) into this array                       "Buzz"
println(  )           # Print, with a newline
\$\endgroup\$
3
\$\begingroup\$

Javascript, 80 bytes

for(i=1;i<101;i++){console.log(i%3==0?i%5==0?"FizzBuzz":"Fizz":i%5==0?"Buzz":i)}
\$\endgroup\$
1
  • \$\begingroup\$ To whoever downvoted this; you really should explain why. Especially considering Jey is a new contributor. \$\endgroup\$
    – Marie
    Feb 27, 2019 at 19:27
3
\$\begingroup\$

Java 8, 129 bytes

interface I{static void main(String[]s){for(int i=0;++i<101;)System.out.println(i%15<1?"FizzBuzz":i%3<1?"Fizz":i%5<1?"Buzz":i);}}

Try it online

\$\endgroup\$
3
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 137 121 114 bytes

I	X =X + 1
	O =EQ(REMDR(X,3)) 'Fizz'
	O =O EQ(REMDR(X,5)) 'Buzz'
	O =IDENT(O) X
	OUTPUT =O
	O =LT(X,100) :S(I)
END

Try it online!

Explanation:

					;* uninitialized variables start as ''
					;* which is coerced to 0 in computations
I	X =X + 1			;* Increment X
	O =EQ(REMDR(X,3)) 'Fizz'	;* if X mod 3 == 0, O = 'Fizz'
	O =O EQ(REMDR(X,5)) 'Buzz'	;* if X mod 5 == 0, concatenate O and 'Buzz'
	O =IDENT(O) X			;* if O is IDENTical to the empty string,
					;* set O to X
	OUTPUT =O			;* print O
	O =LT(X,100) :S(I)		;* set O to '' and if X < 100, goto I
END
\$\endgroup\$
3
\$\begingroup\$

Zsh, 105 78 68 66 61 bytes

Try it online!

for i ({1..100})(((i%3))||w=Fizz;((i%5))||w+=Buzz;<<<${w-$i})

-27 using simpler approach
-10 using parameter fallback
-2 thanks to @Dennis - kudos for the bash solution
-5 thanks to @GammaFunction


Original solution, using weird r flag... try it online

for ((;i++<100;));{f=$[i%3>0?0:4] b=$[i%5>0?0:4]
echo ${(r:$f::Fizz:)}${(r:$b::Buzz:)}`((f+b>0))||<<<$i`}
\$\endgroup\$
4
  • 1
    \$\begingroup\$ You don't need the last ; on the first line. A port to Bash takes 70 bytes, thus beating my answer. \$\endgroup\$
    – Dennis
    Aug 28, 2019 at 14:49
  • 1
    \$\begingroup\$ Also, you don't need the newline before the last } (which is missing in your answer). Try it online! \$\endgroup\$
    – Dennis
    Aug 28, 2019 at 14:56
  • \$\begingroup\$ the bash solution still wins for originality.. I couldn't port that crazy for expression to zsh \$\endgroup\$
    – roblogic
    Aug 28, 2019 at 15:01
  • 1
    \$\begingroup\$ 61, mostly thanks to subshells \$\endgroup\$ Oct 15, 2019 at 2:03
3
\$\begingroup\$

Julia, 87 bytes

z(i)=(f=i .%[3,5] .==0;sum(f)>0 ? foldl(*,["Fizz","Buzz"][f]) : i)
println.(z.(1:100))

Or we could kind of cheat to drop 3 bytes and use show instead of println. Julia 83 bytes

z(i)=(f=i .%[3,5] .==0;sum(f)>0 ? foldl(*,["Fizz","Buzz"][f]) : i)
show(z.(1:100))

or a more legible FP style, poor performing, 91 bytes

F(x)=foldl(*,["Fizz","Buzz"][x .%[3,5] .==0])
N(y)=F(y)=="" ? y : F(y)
println.(N.(1:100))

Julia isn't really made for this, but I had fun thinking about this a bit :).

\$\endgroup\$
5
  • \$\begingroup\$ prod is better than foldr(* \$\endgroup\$
    – H.PWiz
    Nov 23, 2019 at 23:45
  • \$\begingroup\$ Nice! I didn't think that'd work. Either way my solution is 10s of bytes away from the best Julia one :). \$\endgroup\$
    – caseyk
    Nov 23, 2019 at 23:51
  • \$\begingroup\$ Sure. My score is here \$\endgroup\$
    – H.PWiz
    Nov 24, 2019 at 12:25
  • \$\begingroup\$ Woah! How'd you do it? Or is that a secret? :) We have a thread that divulged into codegolf on julia discourse! \$\endgroup\$
    – caseyk
    Nov 24, 2019 at 13:10
  • \$\begingroup\$ Sort of a secret. Although I have discussed julia golfing in a chat room on this site. \$\endgroup\$
    – H.PWiz
    Nov 24, 2019 at 21:56
3
\$\begingroup\$

DIVSPL, 22 bytes

1..100
fizz=3
buzz=5
\$\endgroup\$
3
\$\begingroup\$

W n, 22 21 bytes

Seems like nobody ties with Dennis. Just 1 byte away...

♥:jΓƒ¢D╦Γ%%lOvhI♣BAE§

Uncompressed:

3m!?SY%?*?SZ%?a5m!*+a|2^N

Explanation

                      2^N For Each: 1 to 100
3m!                       Repeat whether current item is divisible by 3
   ?SY%?*                 Repeat that bool by the compressed "Fizz"
         ?SZ%?a5m!*       Do that for "Buzz" too
                   +      Join the results
                    a|    If the result is empty,
                          turn it to the current item value.

Flag: n                   Join the resulting list with newlines
                          Implicit output
```
\$\endgroup\$
3
\$\begingroup\$

Windows Batch, 149 bytes

@for /l %%N in (1 1 100)do @(set s=&set/a1/(%%N%%3^)||set s=Fizz&set/a1/(%%N%%5^)&&(if defined s (echo Fizz)else echo %%N)||call echo %%s%%Buzz)2>nul

The SET /A statements test the modulo 3 and 5 without using IF by intentionally dividing by zero and using && and || conditional command concatenation. Of course stderr must be disabled, but it still saves bytes vs an IF statement.

Windows Batch (unusual cmd.exe configuration, and environment assumption), 166 165 133 bytes

My original answer used delayed expansion, but the code to enable delayed expansion takes 32 bytes all on its own. However, some people have their cmd.exe configured to have delayed expansion enabled by default. For the small minority of people that configure cmd.exe this way, then the following is significantly shorter.

@for /l %%N in (1 1 100)do @(set 1=&set/a1/(%%N%%3^)||set 1=Fizz&set/a1/(%%N%%5^)||set 1=!1!Buzz&>nul set 1&&echo !1!||echo %%N)2>nul

Besides relying on an unusual cmd.exe configuration, it is also reliant on the absence of any environment variable names that begin with 1. This is normally safe because batch treats something like %1var% as batch parameter %1 followed by a string constant var - the trailing % would get stripped. So people are taught to never begin variable names with a digit.

\$\endgroup\$
3
\$\begingroup\$

Integral, 416 Bytes

⌡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⌡[j

Try it

Integral doesn't have very many ways of doing this challenge yet, so this'll have to do for now.

I'll update it once there's a better way.

\$\endgroup\$
1
  • \$\begingroup\$ ah, beautiful solution. what an algorithm. \$\endgroup\$
    – Razetime
    Sep 21, 2020 at 12:57
3
\$\begingroup\$

Japt -R, 27 bytes

Finally came up with a shorter way!

Lõ@"FiBu"ò úz4 ËpXv°EÑÄìªX

Test it

Lõ@"FiBu"ò úz4 ËpXv°EÑÄìªX
L                               :100
 õ                              :Range [1,L]
  @                             :Map each X
   "FiBu"                       :  Literal string
         ò                      :  Partitions of length 2
           úz4                  :  Right pad each with "z" to length 4
               Ë                :  Map each element at 0-based index E
                p               :    Repeat
                 Xv             :      Test X for divisibility by (result will be 1 or 0)
                   °E           :        Prefix increment E
                     Ñ          :        Multiply by 2
                      Ä         :        Add 1
                       Ã        :  End map
                        ¬       :  Join
                         ªX     :  Logical OR with X
                                :Implicit output, joined with newlines
\$\endgroup\$
3
\$\begingroup\$

Python 3, 88 85 77 73 bytes

i=0
exec("i+=1;print(i%3*i%5and i or(i%3<1)*'Fizz'+(i%5<1)*'Buzz');"*100)

Try it online!

\$\endgroup\$
1
3
\$\begingroup\$

jq, 45 bytes

range(100)+1|(1-.%3)*"fizz"+(1-.%5)*"buzz"//.
# explanation
range(100)+1| # for each number in range 0-99 + 1
      . % 3 ) #   the current number modulo 3
 ( 1 -        #   the important thing is this gives 1 for 0 and an invalid
              #   number (0 or negative) for any positive number
       *"fizz"#   "fizz" repeated that many times. For a negative or 0 number
              #   this returns null
 + ..."buzz"  #   concatenated with the same thing but for buzz.
              #   null + anything is that thing, so for a number not divisible by
              #   3 or 5 this returns null
   // .       #   if the result is null, the number itself
              # implicit output

For best results run with jq -rn '...' | less.

\$\endgroup\$
3
\$\begingroup\$

C#, 95 91 bytes

for(int x=0;x++<100;)System.Console.WriteLine((x%3<1?"Fizz":"")+(x%5<1?"Buzz":x%3<1?"":x));

I do not take credit for this solution. I merged two solutions together:

This solution requires C# 9, but does not use Linq.

\$\endgroup\$
3
\$\begingroup\$

Turing Machine Code, 5743 bytes

Should note that Turing Machine Code doesn't process newlines/carriage returns. So everything is necessarily on one line. Thus this may not be, by strict interpretation of the rules, a competing answer due to the nature of the language.

0 * * * 1
1 * 1 r #
# * # * f
f * * l f
f 1 1 l !
f 2 2 l "
f 3 3 l £
f 4 4 l $
f 5 5 l %
f 6 6 l ^
f 7 7 l &
f 8 8 l `
f 9 9 l (
f 0 0 l )
f F F l f
f i i l f
f z z l f
f B B l f
f u u l f
) 1 1 * ¬
) 2 2 * -
) 3 3 * =
) 4 4 * +
) 5 5 * {
) 6 6 * }
) 7 7 * [
) 8 8 * ]
) 9 9 * :
! _ _ r '
! 1 1 r @
! 2 2 * ~
! 3 3 r \
! 4 4 r /
! 5 5 * ,
! 6 6 r .
! 7 7 r <
! 8 8 * >
! 9 9 r ?
" _ _ r a
" 1 1 * b
" 2 2 r c
" 3 3 r d
" 4 4 * e
" 5 5 r ƒ
" 6 6 r g
" 7 7 * h
" 8 8 r ï
" 9 9 r j
£ _ _ r k
£ 1 1 r l
£ 2 2 r m
£ 3 3 * n
£ 4 4 r o
£ 5 5 r p
£ 6 6 * q
£ 7 7 r r
£ 8 8 r s
£ 9 9 * t
$ _ _ r ü
$ 1 1 r v
$ 2 2 * w
$ 3 3 r x
$ 4 4 r y
$ 5 5 * ž
$ 6 6 r A
$ 7 7 r Ɓ
$ 8 8 * C
$ 9 9 r D
% _ _ r E
% 1 1 * Ϝ
% 2 2 * G
% 3 3 * H
% 4 4 * I
% 5 5 * J
% 6 6 * K
% 7 7 * L
% 8 8 * M
% 9 9 * N
^ _ _ r O
^ 1 1 r P
^ 2 2 r Q
^ 3 3 * R
^ 4 4 r S
^ 5 5 r T
^ 6 6 * U
^ 7 7 r V
^ 8 8 r W
^ 9 9 * X
& _ _ r Y
& 1 1 r Z
& 2 2 * α
& 3 3 r β
& 4 4 r γ
& 5 5 * δ
& 6 6 r ε
& 7 7 r ζ
& 8 8 * η
& 9 9 r θ
` _ _ r ι
` 1 1 * κ
` 2 2 r λ
` 3 3 r μ
` 4 4 * ν
` 5 5 r ξ
` 6 6 r ο
` 7 7 * π
` 8 8 r ρ
` 9 9 r ς
( _ _ r σ
( 1 1 r τ
( 2 2 r υ
( 3 3 * φ
( 4 4 r χ
( 5 5 r ψ
( 6 6 * ω
( 7 7 r Α
( 8 8 r Β
( 9 9 * Γ
@ * * r @
@ # _ r Δ
Δ _ 1 r Ε
Ε _ 2 r F
' * * r '
' # _ r 2
2 _ 2 r #
~ * * r ~
~ 2 _ r ~
~ 1 _ r ~
~ # _ r Ζ
Ζ _ 2 r 2
\ * * r \
\ # _ r Η
Η _ 3 r 2
/ * * r /
/ # _ r Θ
Θ _ 4 r Ε
, * * r ,
, 5 _ r ,
, 1 _ r ,
, # _ r Ι
Ι _ 5 r 2
. * * r .
. # _ r Κ
Κ _ 6 r 2
< * * r <
< # _ r Λ
Λ _ 7 r Ε
> * * r >
> 8 _ r >
> 1 _ r >
> # _ r Μ
Μ _ 8 r 2
? * * r ?
? # _ r Ν
Ν _ 9 r 2
a * * r a
a # _ r Ξ
Ξ _ 3 r F 
3 _ 3 r #
b * * r b
b 1 _ r b
b 2 _ r b
b # _ r Ο
Ο _ 1 r 3
c * * r c
c # _ r Π
Π _ 2 r 3
d * * r d
d # _ r Ρ
Ρ _ 3 r Ξ
e * * r e
e 4 _ r e
e 2 _ r e
e # _ r Σ
Σ _ 4 r 3
ƒ * * r ƒ
ƒ # _ r Τ
Τ _ 5 r 3
g * * r g
g # _ r Υ
Υ _ 6 r Ξ
h * * r h
h 7 _ r h
h 2 _ r h
h # _ r Φ
Φ _ 7 r 3
ï * * r ï
ï # _ r Χ
Χ _ 8 r 3
j * * r j
j # _ r Ψ
Ψ _ 9 r Ξ
k * * r k
k 3 _ r k
k # _ r 4
4 _ 4 r #
Ω _ 4 r F
l * * r l
l # _ r ¤
¤ _ 1 r 4
m * * r m
m # _ r ¥
¥ _ 2 r Ω
n * * r n
n 3 _ r n
n # _ r ¦
¦ _ 3 r 4
o * * r o
o # _ r ¨
¨ _ 4 r 4
p * * r p
p # _ r ©
© _ 5 r Ω
q * * r q
q 6 _ r q
q 3 _ r q
q # _ r ª
ª _ 6 r 4
r * * r r
r # _ r «
« _ 7 r 4
s * * r s
s # _ r ®
® _ 8 r Ω
t * * r t
t 9 _ r t
t 3 _ r t
t # _ r °
° _ 9 r 4
ü * * r ü
ü # _ r ±
± _ 5 r B 
v * * r v
v # _ r ²
² _ 1 r ³
³ _ 5 r Ƒ
5 _ 5 r #
w * * r w
w 2 _ r w
w 4 _ r w
w # _ r ¶
¶ _ 2 r ±
x * * r x
x # _ r ·
· _ 3 r ±
y * * r y
y # _ r ¸
¸ _ 4 r ³
ž * * r ž
ž 5 _ r ž
ž 4 _ r ž
ž # _ r ¹
¹ _ 5 r ±
A * * r A
A # _ r »
» _ 6 r ±
Ɓ * * r Ɓ
Ɓ # _ r ¼
¼ _ 7 r ³
C * * r C
C 8 _ r C
C 4 _ r C
C # _ r ½
½ _ 8 r ±
D * * r D
D # _ r ¾
¾ _ 9 r ±
E * * r E
E # _ r ¿
E 5 _ r E
¿ _ 6 r F 
6 _ 6 r #
Ϝ * * r Ϝ
Ϝ 1 _ r Ϝ
Ϝ 5 _ r Ϝ
Ϝ # _ r À
À _ 1 r 6
G * * r G
G 2 _ r G
G 5 _ r G
G # _ r Á
Á _ 2 r 6
H * * r H
H 3 _ r H
H 5 _ r H
H # _ r Â
 _ 3 r ¿
I * * r I
I 4 _ r I
I 5 _ r I
I # _ r Ã
à _ 4 r 6
J * * r J
J 5 _ r J
J # _ r Ä
Ä _ 5 r 6
K * * r K
K 6 _ r K
K 5 _ r K
K # _ r Å
Å _ 6 r ¿
L * * r L
L 7 _ r L
L 5 _ r L
L # _ r Æ
Æ _ 7 r 6
M * * r M
M 8 _ r M
M 5 _ r M
M # _ r Ç
Ç _ 8 r 6
N * * r N
N 9 _ r N
N 5 _ r N
N # _ r È
È _ 9 r ¿
O * * r O
O 6 _ r O
O # _ r 7
7 _ 7 r #
É _ 7 r F
P * * r P
P # _ r Ê
Ê _ 1 r 7
Q * * r Q
Q # _ r Ë
Ë _ 2 r É
R * * r R
R 3 _ r R
R 6 _ r R
R # _ r Ì
Ì _ 3 r 7
S * * r S
S # _ r Í
Í _ 4 r 7
T * * r T
T # _ r Ï
Ï _ 5 r É
U * * r U
U 6 _ r U
U # _ r Ð
Ð _ 6 r 7
V * * r V
V # _ r Ñ
Ñ _ 7 r 7
W * * r W
W # _ r Ò
Ò _ 8 r É
X * * r X
X 9 _ r X
X 6 _ r X
X # _ r Ó
Ó _ 9 r 7
Y * * r Y
Y # _ r 8
8 _ 8 r #
Z * * r Z
Z # _ r Ô
Ô _ 1 r Õ
Õ _ 8 r F
α * * r α
α 2 _ r α
α 7 _ r α
α # _ r Ö
Ö _ 2 r 8
β * * r β
β # _ r ×
× _ 3 r 8
γ * * r γ
γ # _ r Ø
Ø _ 4 r Õ
δ * * r δ
δ 5 _ r δ
δ 7 _ r δ
δ # _ r Ù
Ù _ 5 r 8
ε * * r ε
ε # _ r Ú
Ú _ 6 r 8
ζ * * r ζ
ζ # _ r Û
Û _ 7 r Õ
η * * r η
η 8 _ r η
η 7 _ r η
η # _ r Ü
Ü _ 8 r 8
θ * * r θ
θ # _ r Ý
Ý _ 9 r 8
ι * * r ι
ι # _ r Ā
Ā _ 9 r F 
9 _ 9 r #
κ * * r κ
κ 1 _ r κ
κ 8 _ r κ
κ # _ r Ă
Ă _ 1 r 9
λ * * r λ
λ # _ r Ą
Ą _ 2 r 9
μ * * r μ
μ # _ r Ć
Ć _ 3 r Ā
ν * * r ν
ν 4 _ r ν
ν 8 _ r ν
ν # _ r Ĉ
Ĉ _ 4 r 9
ξ * * r ξ
ξ # _ r Ċ
Ċ _ 5 r 9
ο * * r ο
ο # _ r Đ
Đ _ 6 r Ā
π * * r π
π 7 _ r π
π 8 _ r π
π # _ r Ē
Ē _ 7 r 9
ρ * * r ρ
ρ # _ r Ĕ
Ĕ _ 8 r 9
ς * * r ς
ς # _ r Ė
Ė _ 9 r Ā
Č _ 0 r #
σ * * r σ
σ # _ r Ę
σ 9 _ r σ
Ę _ 1 r Ď
Ď _ 0 r B
τ * * r τ
τ # _ r Ě
Ě _ 2 r Ď
υ * * r υ
υ # _ r Ĝ
Ĝ _ 3 r Ğ
Ğ _ 0 r Ƒ
φ * * r φ
φ 3 _ r φ
φ 9 _ r φ
φ # _ r Ġ
Ġ _ 4 r Ď
χ * * r χ
χ # _ r Ģ
Ģ _ 5 r Ď
ψ * * r ψ
ψ # _ r Ĥ
Ĥ _ 6 r Ğ
ω * * r ω
ω # _ r Ħ
ω 6 _ r ω
ω 9 _ r ω
Ħ _ 7 r Ď
Α * * r Α
Α # _ r Ĩ
Ĩ _ 8 r Ď
Β * * r Β
Β # _ r Ī
Ī _ 9 r Ğ
Γ * * r Γ
Γ 9 _ r Γ
Γ # _ r Ĭ
Ĭ _ B r Į
Į _ u r İ
İ _ z r IJ
IJ _ z r halt
Ĵ _ 1 r #
Ķ _ 1 r F
¬ * * r ¬
¬ 1 _ r ¬
¬ 0 _ r ¬
¬ # _ r Ĺ
Ĺ _ 1 r Ĵ
- * * r -
- 2 _ r -
- 0 _ r -
- # _ r Ļ
Ļ _ 2 r Ķ
= * * r =
= 3 _ r =
= 0 _ r =
= # _ r Ľ
Ľ _ 3 r Ĵ
+ * * r +
+ 4 _ r +
+ 0 _ r +
+ # _ r Ŀ
Ŀ _ 4 r Ĵ
{ * * r {
{ 5 _ r {
{ 0 _ r {
{ # _ r Ł
Ł _ 5 r Ķ
} * * r }
} 6 _ r }
} 0 _ r }
} # _ r Ń
Ń _ 6 r Ĵ
[ * * r [
[ 7 _ r [
[ 0 _ r [
[ # _ r Ň
Ň _ 7 r Ĵ
] * * r ]
] 8 _ r ]
] 0 _ r ]
] # _ r Ņ
Ņ _ 8 r Ķ
: * * r :
: 9 _ r :
: 0 _ r :
: # _ r Ŋ
Ŋ _ 9 r Ĵ
F _ F r i
i _ i r ȥ
ȥ _ z r ź
ź _ z r #
Ƒ _ F r í
í _ i r ż
ż _ z r ƶ
ƶ _ z r B
B _ B r u
u _ u r z
z _ z r ź

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Javastack, 123 bytes

100 times context 1 add "Buzz"context 1 add 5 mod 0 equal repeat "Fizz"context 1 add 3 mod 0 equal repeat add logicor print

Try it online!

Context is everything. This is different to Wasif's Javastack answer because it uses a loop instead of a map, as well as extensive use of the context variable (totally not inspired by a certain golfing language made by a certain cg user with Flowey as his pfp).

Roughly equivalent to:

100ʁ ( n 1+ `Fizz` n 1+ 3 ḋt ¬ẋ `Buzz` n 1+ 5 ḋt ¬ẋ + ⟇, ) 

in vyxal.

You don't know how nice it was to write a Javastack answer without restrictions after 13 rounds of C&R.

\$\endgroup\$
1
  • \$\begingroup\$ I see. Don't worry, there'll be a #10... \$\endgroup\$
    – emanresu A
    Aug 8, 2021 at 19:56
3
\$\begingroup\$

CATHY, 420 bytes

cathYcathycathyCathYcatHYCAthycATHyCatHYCAtHycaThYCAthycATHyCatHYcaThYCAthyCaTHYCatHYcathYCAtHycAThycAThYcathYCAtHycAtHYCatHyCatHYCathYcaTHYcathyCATHycathYcathycaThYCATHycaTHycaTHyCATHycathYcathYcaTHYCATHycAtHycAtHycAtHycatHycAThycathYcatHycatHyCATHycatHycAThYcAtHycAThYcATHycAtHyCatHyCAtHyCathYcATHycAtHyCatHyCatHYcathYCAtHycAThycAThYcathYCAtHycAtHYcathYcathycathyCathYcathyCATHycathycAThYCaTHYCatHycAThYcAtHyCathYCAThY

Try it Online!

What have I done...

In normal form:

100⟑3τƒ:$5τƒ:5τJ:1$/*1$-;:⟑70C105C66C117C+++2/122C2*+*ƒ+;$⟑ƒ+;:1$/*1$-100⟑0C0*J;*+⟑,
=== Part 1: divisors ===
100⟑3τƒ:$5τƒ:5τJ:1$/*1$-;
100⟑                    ; # Map 1...100 to...
    3τƒ:                  # Convert to base 3 and get the last (dup-reduce)
        $5τƒ:             # Also convert to base 5 and get last (dup-reduce)
             5τJ          # Wrap in a list by converting to base 5 again, and concat
                :1$/      # Duplicate and take reciprocal
                    *     # Multiply, resolving 1+s to 1 and 0s to 0
                     1$-  # Subtract from 1
                          # Leaving [divisible by 3, divisible by 5]

=== Part 2: Fizz and Buzz ===
:⟑70C105C66C117C+++2/122C2*+*ƒ+;
:⟑                             ; # Duplicate previous and map to...
  70C105C66C117C+++              # Construct string "FiBu"
                   2/            # Divide into two pieces
                     122C        # chr(122) = z
                         2*+     # Double and append to each
                            *ƒ+  # Repeat by the above and concatenate
=== Part 3: Putting it together ===
$⟑ƒ+;:1$/*1$-100⟑0C0*J;*+⟑,
$⟑ƒ+;                       # Swap and sum each
     :1$/*1$-               # Turn 2s into 1s
             100⟑     ;     # Map 1...100 to...
                 0C0*J      # Concatenate the empty string (stringify)
                       *    # Repeat numbers by amounts
                        +   # Concatenate
                         ⟑, # Over each, print
\$\endgroup\$
3
\$\begingroup\$

Dart, 88

main({i=0}){while(i<100)print(["FizzBuzz","Fizz","Buzz",++i][(i%3).sign*2+(i%5).sign]);}

Dart is somewhat hampered in the golfing by not having conversion between bool and int, but the sign getter on integers helps a little.

\$\endgroup\$
3
\$\begingroup\$

Klong [klongpy], 62 bytes

,/{Z:::[x!3;"";"Fizz"],:[x!5;"";"Buzz"];:[Z;Z;$x],:#10}'1+!100

A nifty little K-like language I found on reddit. Uses the klongpy interpreter rather than the official C Klong interpreter.

Explained

,/{...}'1+!100
       '       :" To each item (x) in...
        1+!100 :" the range [0, 100) + 1 -> [1, 100]...
  {...}        :" map the function described in the next code block
,/             :" join into a single string
Z:::[x!3;"";"Fizz"],:[x!5;"";"Buzz"];:[Z;Z;$x],:#10
Z::                                                   :" Define Z to be:
                   ,                                  :" The concatenation of:
   :[x!3;"";"Fizz"]                                   :" "Fizz" if x % 3 == 0, else "" (note that the condition isn't actually x % 3 == 0 - it'd need to be something like 0=x!3. The order of the truthy and falsey branches has been swapped to accomodate this)
                    :[x!5;"";"Buzz"]                  :" and "Buzz" if x % 5 == 0, else "" (same note applies as above)
                                    ;:[Z;Z;$x]        :" if Z isn't empty, return whatever Z is, else str(x)
                                              ,:#10   :" And add a newline (chr(10)) to that
\$\endgroup\$
1
  • \$\begingroup\$ i can’t test it but does ,/{([$x"Fizz""Buzz""FizzBuzz"]@(0=x!3)+2*0=x!5),:#10}'1+!100 work for 60? \$\endgroup\$
    – noodle man
    May 9 at 13:35
3
+50
\$\begingroup\$

Typescript Type System + ts-arithmetic, 257 bytes

import{Mod,Add}from"ts-arithmetic"
type x<n extends 0>=`${Mod<n,3>extends 0?"Fizz":""}${Mod<n,5>extends 0?"Buzz":""}`
type c<n extends 0>=x<n>extends""?n:x<n>
type a<z,n=1>=`${c<n>}
${n extends z?"":a<z,Add<n,1>>}`
type _=`${a<33>}
${a<66,33>}
${a<100,66>}`

Try it at TS Playground

The output is in the _ type, not emitted to STDOUT because the TS type system doesn't have that.

I've done some golfing but this can still be golfed heavily, maybe below 200 with a slightly different technique.

Unfortunately, we can't have type _=a<100> because TS won't generate recursive types more than 45-ish layers deep, so it has to be separated into three segments

\$\endgroup\$
4
3
\$\begingroup\$

Uiua, 48 bytes

∵(&p□/⊂∵!♭▽∶⊂{"Fizz""Buzz"}∶⊂∶¬/↥.=0◿3_5.)+1⇡100

Try it Online

What if APL but stack? That's the core question of Uiua and given that the shortest APL fizzbuzz is 7 bytes shorter, I clearly aren't stacking efficiently.

Explained

∵(&p□/⊂∵!♭▽∶⊂{"Fizz""Buzz"}∶⊂∶¬/↥.=0◿3_5.)+1⇡100­⁡​‎⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏⁠‎⁡⁠⁣⁤⁡‏⁠‎⁡⁠⁣⁤⁢‏⁠‎⁡⁠⁣⁤⁣‏⁠‎⁡⁠⁣⁤⁤‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣⁣⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡⁣‏⁠‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏⁠‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁤⁡‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏⁠‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠‎⁡⁠⁢⁣⁤‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁣⁡​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏‏​⁡⁠⁡‌­
                                          +1⇡100  # ‎⁡The range [1, 100]
∵(                                       )        # ‎⁢To each number n in that range
                                  =0◿3_5          # ‎⁣  Push whether the number is divisible by 3 and 5
                            ⊂∶¬/↥.                # ‎⁤  Append to that list the maximum. This serves as a check as to whether the number should be printed, or a fizzbuzz string.
            ⊂{"Fizz""Buzz"}∶                      # ‎⁢⁡  The list ["Fizz", "Buzz"] with n appended. These are all constants (i.e. functions that return the value) for array model reasons.
          ▽∶                                      # ‎⁢⁢  Use the modulo mask from earlier to select values from ^
     /⊂∵!♭                                        # ‎⁢⁣  Flatten, deconstantify each, and join into a single 1d array
    □                                             # ‎⁢⁤  Wrap back in a constant for array model reasons
  &p                                              # ‎⁣⁡  And print the result on STDOUT
💎

Created with the help of Luminespire.

\$\endgroup\$
2
\$\begingroup\$

Ceylon, 368 144 123 96 bytes

shared void z(){for(i in 1..100){print(["FizzBuzz","Buzz","Fizz",i][(i%5).sign*2+(i%3).sign]);}}

Here we have the ungolfed original of 368 bytes:

shared void fizzBuzz() {
    for(i in 1..100) {
        if(3.divides(i)){
             if(5.divides(i)) {
                 print("FizzBuzz");
             } else {
                 print("Fizz");
             }
        } else {
            if(5.divides(i)) {
                print("Buzz");
            } else {
                print(i);
            }
        }
    }
}

In Ceylon, Integers are also just objects, so one can call methods on them (like the divides method here).

1..100 is syntactic sugar for span(1, 100), which is a Range<Integer>, which implements Iterable<Integer>, and can therefore be used with the for loop.

The print function takes one argument (of type Anything), stringifies it (i.e. if it's an object, calls its .string attribute, if it's null, takes "<null>") and prints it to the standard output.

Removing whitespace, using a shorter function name, and replacing x.divides(y) by the shorter y%x==0, which is essentially how divides is implemented, gives us this (144 bytes):

shared void f(){for(i in 1..100){if(i%3==0){if(i%5==0){print("FizzBuzz");}else{print("Fizz");}}else{if(i%5==0){print("Buzz");}else{print(i);}}}}

Of course, this is not the best which is possible ... this uses print and if much too often, and also does the check for divisibility by 5 twice.

Integers (or Numbers types in general) have also the .sign attribute, which is 1 for positive numbers, 0 for zero, and -1 for negatives. We can use that together with the remainder operator to get a different value for each of the four cases: (i % 5).sign * 2 + (i % 3).sign]. This is 0 for FizzBuzz, 1 for Buzz, 2 for Fizz and 3 for the "plain" case. We can use this as an index of a tuple, coming to this 123-bytes program:

shared void z() {
    for(i in 1..100) {
        print(["FizzBuzz", "Buzz", "Fizz", i][(i%5).sign*2 + (i%3).sign]);
    }
}

([...] is the syntax for both Tuple creation (here a Tuple with element types String, String, String, Integer, formally Tuple<String|Integer, String, Tuple<String|Integer, String, Tuple<String|Integer, String, Tuple<Integer, Integer, Empty>>>, which can be written shorter as [String, String, String, Integer]) and lookup in a Correspondence (and this tuple type implements Correspondence<Integer, String|Integer>).

Removing the whitespace again gives us this 96 byte program:

shared void z(){for(i in 1..100){print(["FizzBuzz","Buzz","Fizz",i][(i%5).sign*2+(i%3).sign]);}}
\$\endgroup\$
2
\$\begingroup\$

VB.Net, 147 146 bytes

Module F
Sub Main()
For i=1To 100
Dim a=i Mod 3,b=i Mod 5
Console.WriteLine("{0:#}{1:;;Fizz}{2:;;Buzz}",If(a*b>0,i,0),a,b)
Next
End Sub
End Module

It uses the same conditional formatting trick as the C# answer by Pierre-Luc Pineault.

UPDATED: saved 1 byte thanks to Brian J

\$\endgroup\$
1
  • \$\begingroup\$ you can save a byte by using If instead of IIf. The difference is that IIf is a function that will evaluate both the true and false options, while If is an operator that will only evaluate the option it needs. Functionally doesn't make a difference in this case, but does save a character. \$\endgroup\$
    – Brian J
    Sep 25, 2015 at 13:13
2
\$\begingroup\$

zsh, 65 63 bytes

repeat 100 x=|let ++i%3||x=Fizz&&let i%5||x+=Buzz&&<<<${x:-$i}

Changed echo to <<<. It's now 2 bytes shorter, because <<< doesn't need a space.

repeat 100 x=|let ++i%3||x=Fizz&&let i%5||x+=Buzz&&echo ${x:-$i}

\$\endgroup\$
2
\$\begingroup\$

Python 2, 148 133 Bytes

def f(n):
 if n%3+n%5<1:return"FizzBuzz"
 if n%5<1:return"Buzz"
 if n%3<1:return"Fizz"
 return n
for x in map(f,range(1,101)):print x
\$\endgroup\$
5
  • \$\begingroup\$ it is possible to save some bytes by reducing the amount of indentation. (1 space is sufficient) \$\endgroup\$
    – Mohammad
    Sep 27, 2015 at 18:12
  • 1
    \$\begingroup\$ @Mhmd it's probably actually tabs, SE converts them to 4 spaces. \$\endgroup\$ Sep 27, 2015 at 22:18
  • \$\begingroup\$ if n%3+n%5==0:return"FizzBuzz" -> if n%3+n%5==0:return f(3)+f(5) EDIT: nevermind i miscounted, it's the same \$\endgroup\$ Sep 27, 2015 at 22:19
  • 1
    \$\begingroup\$ oh, but you can change ==0 to <1 everywhere it appears \$\endgroup\$ Sep 27, 2015 at 22:58
  • 1
    \$\begingroup\$ This can be shortened significantly by removing the function and return logic: for i in range(100):print(i%3+i%5<1and'FizzBuzz')or(i%5<1and'Buzz')or(i%3<1and'Fizz')or i golfs it down to 89 bytes. \$\endgroup\$
    – Skyler
    Oct 26, 2015 at 13:47
2
\$\begingroup\$

C# using LINQ, 168 186

using System.Linq;class A{static void Main(){foreach(var s in Enumerable.Range(1,100).Select(n=>n%3==0?n%5==0?"FizzBuzz":"Fizz":n%5==0?"Buzz":n.ToString()))System.Console.WriteLine(s);}}
\$\endgroup\$
0
2
\$\begingroup\$

haxe, 110 bytes

class Main{
  static function main()
    for(i in 1...101)
      Sys.println(i%3<1?"Fizz"+(i%5<1?"Buzz":""):i%5<1?"Buzz":i);
}

(newlines and indents added for clarity)

Haxe isn't much of a golfing language … I was trying to do something with enumerators:

class Main{
  static function main()
    for(i in 1...101)
      Sys.println(
        switch(i){
          case _%3=>0:i%5<1?"FizzBuzz":"Fizz";
          case _%5=>0:"Buzz";
          case _:i;
        }
      );
 }

But 140 bytes. :I

\$\endgroup\$
2
\$\begingroup\$

C#, 155 142 Bytes

class a{static void Main(){for(int i=0;i++<100;){var s="";if(i%3<1)s="Fizz";if(i%5<1)s+="Buzz";if(s=="")s=i+"";System.Console.WriteLine(s);}}}

Added as an alternate approach to the example using LINQ

Thanks @Riokmij!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can replace the ==0's with <1, change the declaration of s with var instead of string, and replace the call to .ToString() by +"". Also, initial value for i should be 0. \$\endgroup\$
    – Najkin
    Sep 29, 2015 at 15:56
2
\$\begingroup\$

MSX-BASIC, 106 bytes

1FORI=1TO100:IFIMOD3=0ANDIMOD5=0THEN?"FizzBuzz"ELSEIFIMOD3=0THEN?"Fizz"ELSEIFIMOD5=0THEN?"Buzz"ELSE?I
2NEXT

The one-liner version to be executed in direct mode would be 120 bytes because all of the extra NEXTs needed before the ELSEs:

FORI=1TO100:IFIMOD3=0ANDIMOD5=0THEN?"FizzBuzz":NEXTELSEIFIMOD3=0THEN?"Fizz":NEXTELSEIFIMOD5=0THEN?"Buzz":NEXTELSE?I:NEXT
\$\endgroup\$
1
  • 1
    \$\begingroup\$ IFIMOD3=0ANDIMOD5=0 -> IFIMOD15=0? I think MSX BASIC could be tokenized too, which would decrease your byte count. \$\endgroup\$
    – lirtosiast
    Sep 30, 2015 at 14:53
2
\$\begingroup\$

rs, 92 91 bytes

(_)^^(100)
+^(_+)(_)/\1 \1\2
\b((___)+)\b/Fi;\1
\b(_{5})+\b/Bu;
;_*/zz
\b(_+)\b/(^^\1)
 /\n

Saved 1 byte thanks to @MartinBüttner!

Live demo. (It may take a bit to run!)

\$\endgroup\$
6
  • \$\begingroup\$ Do you not have \0 in rs? You can probably save some bytes either way by using the trick from my Retina answer: \b((___)+)\b/Fi;\1 ... \b(_{5})+\b/Bu; ... ;_+/zz \$\endgroup\$ Sep 28, 2015 at 14:38
  • \$\begingroup\$ @MartinBüttner Thanks! I updated the post. What exactly do you mean by \0? \$\endgroup\$ Oct 1, 2015 at 19:44
  • \$\begingroup\$ Something to reference the entire match, not just a capturing group. \$\endgroup\$ Oct 1, 2015 at 19:59
  • \$\begingroup\$ @MartinBüttner I guess not. :( \$\endgroup\$ Oct 1, 2015 at 20:05
  • \$\begingroup\$ @MartinBüttner I'm just using Python's built-in substitution thing. I can easily override it, though... \$\endgroup\$ Oct 1, 2015 at 20:06
1
4 5
6
7 8
14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.