Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

1, 2, Fizz, 4, Buzz!

+9
−0

The task

Output the first 100 elements of the infamous FizzBuzz sequence.

How?

The FizzBuzz sequence is the sequence of decimal integers from 1 to 100 inclusive, but:

  • If the integer is divisible both by 3 and 5, output the string FizzBuzz
  • Else, if the integer is divisible by 3, output the string Fizz instead
  • Else, if the integer is divisible by 5, output the string Buzz instead
  • Else, output the integer itself

Output

The output will be a list of these elements separated by either a space (U+0020) or a newline (U+000A).

Here is a sample output with newline separation:

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

Rules

  • Your code may not print anything to STDERR. Warnings are fine.
  • This is code-golf, so lowest byte-count in each language is the winner.
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (7 comments)

21 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+2
−0

AWK, 72 bytes

BEGIN{for(i=1;i<101;i++){s="";i%3||s="Fizz";i%5||s=s"Buzz";print s?s:i}}

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+6
−0

C (gcc), 113 Bytes

i;main(){while(i++<100){char*h[]={"%d "," "},**p=h;i%3||(*p++="Fizz%2$s");i%5||(*p="Buzz ");printf(*h,i,h[1]);}}

This compiles with several warnings, but no errors.

Here's an ungolfed version with explanations:

/* the following include is omitted; while using printf
   without including it is not conforming to the current
   C standard, with gcc it only generates a warning
   and works flawlessly. Note that omission was valid K&R C */
#include <stdio.h>

/* Declare a global int variable. The golfed code omits the
   type because of the old implicit-int rule, which only
   generates a warning also in modern gcc. Also note that
   global variables without initializer are zero-initialized;
   this is still defined behaviour today. In this ungolfed
   code I've added the implied initializer for clarity. */
int i=0;

/* The main function. Again, the golfed code makes use of the
   old implicit int rule. */
int main()
{
  /* loop up to 100; since we increment before entering the
     loop body, the first number in the loop is 1. */
  while(i++<100)
  {
    /* In this array of two strings, the first will be used as
       format string to a printf later, while the second will
       be the third argument for the same printf. As is, the
       format string will tell printf to format the second
       argument (which will be i) as number, followed by a space.
       The third argument, a single-space string, is ignored
       in that case. */
    char *h[] = { "%d ", " " };

    /* This second variable (which in the golfed version is
       declared in the same declaration as h) points to the first
       entry of h. It is used to change the entries of h, and
       it is separate because pointer arithmetic is used to
       modify different strings depending on the condition. */
    char **p = h;

    /* This is basically an if-not statement. If i%3 is not
       nonzero (that is, if i is divisible by 3), this statement
       replaces the format string with one that prints "Fizz"
       followed by the content of the third argument of printf
       as string, which is the second string in h. At this
       point it contains just a space. Also, when replacing the 
       format string, the pointer p is incremented, so it then
       points to the second element of h. */
    i%3 || (*p++ = "Fizz%2$s");

    /* This if-in-disguise handles divisibility by 5. It stores
       a pointer to "Buzz " into whatever p points to. If i
       is not divisible by 3, this still is the format string,
       so if instructs the following printf to just print "Buzz "
       and ignore any further arguments. Otherwise, p points
       to the final string argument, so that after the "Fizz"
       it prints "Buzz " instead of just a space. */
    i%5 || (*p = "Buzz ");

    /* This finally is the printf statement talked about
       in the previous comments. Note that *h is equivalent
       to h[0] */
    printf(*h,i,h[1]);
  }
}
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (1 comment)
+4
−0

RoadLang, 340 bytes

wagwan my slime
x is 0
rip dat bong till x bigger den 99 n dat
x is x n 1
ayy bossman (x leftova 15) be 0 init bruv
man say"FizzBuzz"
yeah init bruv
ayy bossman (x leftova 5) be 0 init bruv
man say"Buzz"
yeah init bruv 
ayy bossman (x leftova 3) be 0 init bruv
man say"Fizz"
yeah init bruv 
man say x
yeah
yeah
yeah
mmm
chat wit u later fam

Make sure you rip dat bong dis christmas eve!

Here's a more slimy answer:

wagwan my slime
I is nuttin
rip dat bong till I bigger den 99 n dat
	I is I n bar
	ayy bossman (I leftova (beehive x bender ova bice) ) be 0 init bruv
		man say "FizzBuzz"
	yeah init bruv
		ayy bossman (I leftova beehive) be nuttin init bruv
			man say "Buzz"
		yeah init bruv 
			ayy bossman (I leftova bender ova bice) be 0 init bruv
				man say "Fizz"
			yeah init bruv 
				man say I
			yeah
		yeah
	yeah
mmm
chat wit u later fam
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (1 comment)
+4
−0

JavaScript (Node.js), 64 bytes

for(n=0;101>++n;)console.log([['Fizz'][n%3]]+[['Buzz'][n%5]]||n)

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+4
−0

goruby, 1 byte

f

Okay, so that's a bit unfair. 😂 The definition of f from golf_prelude.rb (which is what goruby embeds) is quite golfy in itself:

def f(m = 100)
  1.upto(m){|n|puts'FizzBuzz
'[i=n**4%-15,i+13]||n}
end

Substituting m with 100 directly gives us the Ruby version, which weighs in at 51 bytes:

1.upto(100){|n|puts'FizzBuzz
'[i=n**4%-15,i+13]||n}
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

Japt -R, 28 bytes

Lõ@"Fizz"pXv3)+"Buzz"pXv5)ªX

I spent a long time playing with wizardry string/array slicing. It did not work out. This solution just repeats "Fizz" and "Buzz" if divisible.

Test it

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (3 comments)
+3
−0

C (gcc), 108 bytes

*h,i;main(){for(;i++<100;){char s[]="%dFizzBuzz ",b=i%5;h=s+2;printf(s+(i%3?b?*h=32,0:6:b?h[1]=32,2:2),i);}}

Godbolt. Works on clang too. Contains some serious abuse of all that is holy: gcc extensions, misaligned writes, endianess, poorly-defined behavior...

Newline instead of space, 109 bytes:

*h,i;main(){for(;i++<100;){char s[]="%dFizzBuzz\n",b=i%5;h=s+2;printf(s+(i%3?b?*h=10,0:6:b?h[1]=10,2:2),i);}}

I'm a rookie at code golf so this could probably be improved a lot.


Explanation:

The whole code is based on a local string s which is refreshed at each lap of the loop.

Basically the whole expression is a big if-else written with ?:, designed to return a pointer offset to the string as result.

  • In case a normal number should be printed, a space and null terminator is inserted after %d.
  • In case FizzBuzz should be printed, the array offset is increased with pointer arithmetic to start from Fizz.
  • In case only 'Fizz' should be printed, a space + null terminator is inserted after Fizz.
  • In case only 'Buzz' should be printed, the array offset is increased with pointer arithmetic.

Space + null terminator is written by a lvalue access of int through h to the string, which is both a strict aliasing violation, a misaligned access and endianess reliance all at once. The raw data of 0x00000020 is written into the string, little endian meaning that 0x20 ends up in ls byte and then a 0x00 byte after that, forming a null terminator.

printf is abused by getting passed an additional parameter i whether or not the format string contains any conversion specifier.

gcc extensions abused:

  • implicit int
  • main() form and no return 0 in case of C90.
  • no #include
  • incompatible pointer conversion from char* to int*.
  • Dodging strict pointer aliasing
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

Shakespeare Programming Language, 11232 bytes

My last attempt was nearing the 20000 byte zone, because it didn't use the stack at all.

a.Ajax,.Puck,.Ford,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:You is twice the sum ofa cat a big big cat.Puck:You is the sum oftwice the sum ofthe cube ofa big big cat a big pig a big pig.Scene V:.[Exeunt][Enter Ajax and Puck]Puck:Remember you!Remember you!Remember the sum ofthe sum ofyou a big big pig a pig!Remember the sum ofthe cube ofa big big cat a big cat!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big pig a pig!Remember the sum ofthe cube ofa big big cat a big cat!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big pig a pig!Remember the sum ofthe cube ofa big big cat a big cat!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me![Exit Ajax][Enter Ford]Puck:You is the sum ofyou a cat!Be you worse twice the sum ofa big cat a cat?If soLet usScene V![Exit Ford][Enter Ajax]Puck:Remember you!Remember you!Remember the sum ofthe sum ofyou a big big pig a pig!Remember the sum ofthe cube ofa big big cat a big cat!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big pig a pig!Remember the sum ofthe cube ofa big big cat a big cat!Remember me!Remember me!Remember you!Remember you!Remember the sum ofthe sum ofyou a big big big big pig a pig!Remember the sum oftwice the sum ofa big cat a cat the cube ofa big big cat!Remember me!Remember me!Puck:You cat!Open heart!Recall!Speak thy!You big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a pig!Open heart!Recall!Speak thy!You big big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You cat!Open heart!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofthe sum ofa big cat a cat you!Open heart!Recall!Speak thy!You is the sum ofyou a big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big big big cat!Open heart!Recall!Speak thy!You is the sum ofa big big big big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You cat!Open heart!You is the sum ofa big big big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big cat!Open heart!Open heart!Recall!Speak thy!You big cat!Open heart!You is the sum ofyou a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big cat!Open heart!You is twice the sum ofyou a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is twice the sum ofyou a big big cat!Open heart!Recall!Speak thy!You big cat!Open heart!You is the sum ofa big big big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big cat a cat!Open heart!You cat!Open heart!Recall!Speak thy!You big big big big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is twice the sum ofa big big big big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum oftwice twice the sum ofa big big big cat a cat a cat!Open heart!Recall!Speak thy!You is twice the sum oftwice the sum ofa big big big cat a cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big cat!Open heart!You cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big cat!Open heart!You is the sum ofyou a pig!Open heart!Recall!Speak thy!You big big cat!Open heart!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big cat!Open heart!You is the sum ofyou a big cat!Open heart!Recall!Speak thy!You big big cat!Open heart!You is the sum oftwice you a pig!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the square ofthe sum ofa big big big cat a pig!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big cat a cat!Open heart!You big cat!Open heart!Recall!Speak thy!You is the sum oftwice the sum ofthe factorial ofa big big cat a big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is twice twice the sum ofyou a big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big cat a cat!Open heart!You big big big cat!Open heart!Recall!Speak thy!You is the sum ofa big big cat a cat!Open heart!You is the sum ofyou a big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is twice the sum ofa big cat a cat!Open heart!You cat!Open heart!Recall!Speak thy!You is the sum ofthe cube ofa big big cat a big pig!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the cube ofa big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofthe sum ofthe cube ofa big big cat a big cat a cat!Open heart!Recall!Speak thy!You is the sum ofthe cube ofa big big cat a big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a pig!Open heart!You cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum oftwice the square oftwice the sum ofa big cat a cat a cat!Open heart!Recall!Speak thy!You is the sum oftwice the square oftwice the sum ofa big cat a cat a big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum oftwice the square oftwice the sum ofa big cat a cat a big big cat!Open heart!Recall!Speak thy!You is the sum ofa big big big cat a pig!Open heart!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a pig!Open heart!You is the sum ofyou a big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big big cat!Open heart!You big cat!Open heart!Recall!Speak thy!You big big big cat!Open heart!You is the sum ofa big cat a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big big cat!Open heart!You is the sum ofyou a big pig!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You big big big cat!Open heart!Open heart!Recall!Speak thy!You big big big cat!Open heart!You is the sum ofyou a cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a cat!Open heart!You cat!Open heart!Recall!Speak thy!You is the sum ofa big big big cat a cat!Open heart!You big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a cat!Open heart!You big big cat!Open heart!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!Recall!Speak thy!You is the sum ofa big big big cat a cat!Open heart!You is the sum ofyou a big pig!Open heart!Recall!Speak thy!You is the sum ofthe square ofyou a big pig!Open heart!Ajax:You is the sum oftwice the sum ofa big big cat a cat a cat!Scene L:.Puck:Recall!Speak thy!Ajax:You is the sum ofyou a pig!Be you nicer a cat?If soLet usScene L!

Works by adding the FizzBuzz line breaks and words to the stack (in reverse) for the first 90, adds the last 10 lines, then goes through and prints all the numbers and words by recalling the stack at specific times. SPL doesn't support division so this is the shortest method I could think of, short of subtracting numbers and checking if they... equal... zero...

Oh god, I've gotta go golf more. I'm leaving this here as a mark that I've done something, though.

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Another way might be to keep two counters, and output Fizz/Buzz when they reach 3/5 (and then reset t... (1 comment)
+2
−0

Vyxal Hj, 10 bytes

ƛ₍₃₅kF½*∑∴

Try it Online!

Vyxal has gotten a whole lot better since first posting this.

Explained

Very simply, this is: for each item in the range [1, 100], create the list [item % 3 == 0, item % 5 == 0], multiply that by ["Fizz", "Buzz"], sum that and get the maximum of the number and the summed list.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Canvas, 24 bytes

zz+¹┘%!*
‾U{ŗ3Fi⁸5Bu⁸+nO

Try it here!

Explanation (ASCII-fied for better monospacing):

zz+¹┘%!*  Helper function ⁸; Expects stack to be [modulo, string]
zz+       append "zz" to the string
   ¹      push the current loop index
    ┘     retrieve the modulo
     %    calculate the modulo
      !   negate (i.e. is-divisible)
       *  repeat the string vertically that many times

‾U{ŗ3Fi⁸5Bu⁸+nO  Main program
‾U{              Repeat 100 times, pushing index & writing it to ¹
   ŗ             stringify the pushed index
    3Fi⁸         invoke ⁸ on [3; "Fi"]
        5Bu⁸     invoke ⁸ on [5; "Bu"]
            +    join the two results
             n   overlap that over the index; this works as the maximum index, 100, is less than 4 characters
              O  output that
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

Japt -R, 27 bytes

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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Haskell, 110 bytes

main=mapM(\n->putStrLn$case(rem n 3,rem n 5)of(0,0)->"FizzBuzz";(0,_)->"Fizz";(_,0)->"Buzz";_->show n)[1..100]

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

shortC, 95 93 91 bytes

AIi;Wi++<100){C*h[]={"%d "," "},**p=h;i%3||(*p++="Fizz%2$s");i%5||(*p="Buzz ");R*h,i,h[1]);

Try it online!

From @celtschk's C (gcc) answer.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Rockstar, 138 135 133 bytes

F takes I&S
let M be N/I
turn up M
if N-I*M
S's""

return S

N's0
while N-100
let N be+1
say F taking 3,"Fizz"+F taking 5,"Buzz" or N

Try it here (Code will need to be pasted in)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Julia 1.0, 79 bytes

println.(i%15<1 ? "FizzBuzz" : i%3<1 ? "Fizz" : i%5<1 ? "Buzz" : i for i=1:100)

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

C (gcc), 103 bytes

Using a different approach than my previous solution, therefore posting as new answer as suggested here.

i;main(){while(i++<100){char s[]="FizzBuzz",*t=s+4*!!(i%3);if(i%5)s[4]=0;*t?puts(t):printf("%d\n",i);}}

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Sclipting, (UTF-16) 62 bytes

감 뉀上標❷갰剩虛끦땺뎠嗎❸걐剩虛뀧녺뎠嗎併梴是⓶終丟終并겠會
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Lua, 126 118 bytes

p=print for i=1,100 do if i%15==0 then p"FizzBuzz"elseif i%3==0 then p"Fizz"elseif i%5==0 then p"Buzz"else p(i)end end

Try it online!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 64 62 bytes

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

Try it online!

Saved two bytes thanks to Moshi‭ in the comments.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

2 comment threads

`==0` -> `<1` (1 comment)
General (1 comment)
+0
−0

PHP, 114 bytes

<?php for($i=1;$i<101;$i++){if($i%3!=0&$i%5!=0){echo$i;}if($i%3==0){echo"Fizz";}if($i%5==0){echo"Buzz";}echo"\n";}

Try it online!

As someone who doesn't code much in Philippine Peso this language, it was tricky.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »