Fizzbuzz thread. In the language of your choice write a program that prints "fizz" for multiples of 3...

Fizzbuzz thread. In the language of your choice write a program that prints "fizz" for multiples of 3, "buzz" for multiples of 5, "fizzbuzz" for multiples of both, and the number for multiples of neither.

puts (1..100).map { |i| (fb = [["Fizz"][i % 3], ["Buzz"][i % 5]].compact.join).empty? ? i : fb }

main = do
let x = concat [if x `mod` 15 == 0 then "fizzBuzz!\n"
else if x `mod` 5 == 0 then "Buzz!\n"
else if x `mod` 3 == 0 then "fizz!\n"
else show x ++ "\n" | x

1/10 for technically solving the problem

public final class FizzBuzz {
public static void main(String[] args) {
for(int i = 0; i

what the shitting dick nipple is this

Ruby. Just started using it this year and it's been fun. Coming from a C++/c#/Java background, it's a fresh breath of weirdly pleasing air.

>using an extra modulo instead of reusing the results of the two orhet modulo

I get that you're trying to be clever by using a more "mathematical" approach but that you're actually doing is sacrificing basic logic and using a lot of extra CPU cycles

You are wasting so many CPU cycles

for(let i = 1; i

go away evil dogger.

for n in range(1, 101):
if n % 15 == 0:
print "FizzBuzz"
elif n % 3 == 0:
print "Fizz"
elif n % 5 == 0:
print "Buzz"
else:
print n
raw_input()


How shitty is my code?

Not as shitty as OP's so you're fine.

Oops, forgot to check the modulo result. Both if statements should be
if (i % 3|5 === 0)

Or I suppose this would work too
if (!(i % 3|5))

Fine other than using input at the end and using python 2 instead of 3.

Alright smartasses, how would you do it then?

int n = 0;
bool printed;
while (n < 100)
{
fizzed = false;
if (!(n % 3)) printf("Fizz"); printed = true;
if (!(n % 5)) printf("Buzz"); printed = true;
if (!printed) printf("%i, ", n);
++n;
}

coming for your jobs

let rec f n s =
if n > 100
then print_string s
else f (n+1) (s ^ (
if (n mod 15) = 0
then "fizzbuzz\r\n"
else
if (n mod 3) = 0
then "fizz\r\n"
else
if (n mod 5) = 0
then "buzz\r\n"
else (string_of_int n) ^ "\r\n"
))
in
f 0 ""

niggers

>printed is not used
>fizzed is not defined

>\r\n

Might as well double click fizzBuzz.exe at this point, pajeet.

What's wrong with using \r\n?

"fizzed" is supposed to be "printed" but brainfart

program fizzbuzz;
var
i:integer;

begin
for i:=1 to 100 do
begin
if (i mod 3=0) and (i mod 5=0) then
writeln('FizzBuzz')
else if (i mod 5=0) then
writeln('Buzz')
else if (i mod 3=0) then
writeln('Fizz')
else
writeln(i);
end;
end.

for(i=0;i++

class FizzBuzzCommandlet extends Commandlet;

event int Main(string Parms)
{
local int i;
local string S;

while(i++ < 100)
{
S = "";
if(i % 3 == 0)
S $= "Fizz";
if(i % 5 == 0)
S $= "Buzz";
Log(Eval(S=="",i,S));
}
return 0;
}

##FizzBuzz
for num in xrange(1,101):
msg = ''
if num % 3 == 0:
msg += 'Fizz'
if num % 5 == 0:
msg += 'Buzz'
print msg or num

private static void fizzBuzz(int length)
{
IntStream.range(1, length).forEach(i ->
{
String s = "";

if (i % 3 == 0) s += "Fizz";
if (i % 5 == 0) s += "Buzz";
if (s.isEmpty()) s += String.valueOf(i);

System.out.println(s);
});
}

ok

for (var i = 1; i < 101; i++) {document.body.innerHTML += '' + i + ''}; document.querySelectorAll('script')[0].remove()

div:nth-child(3n):before{content: "Fizz"}
div:nth-child(5n):after{content: "Buzz"}
div:nth-child(3n):before, div:nth-child(5n):after{font-size: initial}
div:nth-child(3n), div:nth-child(5n){font-size: 0}
div{font-family: Helvetica; font-weight: 300}


Works in chromium

Good work, Daniel

how about the weirdest language you can code on huh?

>inb4 that fag that posts a solution with tensorflow

IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZBUZZ.

DATA DIVISION.
01 CUNT PIC 9(3) VALUE 001.
01 REMAINDER PIC 9(3) VALUE 000.
01 FIZZ PIC A(4) VALUE "FIZZ".
01 BUZZ PIC A(4) VALUE "BUZZ".

PROCEDURE DIVISION.
A-PARA.
PERFORM B-PARA UNTIL CUNT>100.
STOP RUN.

B-PARA.
COMPUTE REMAINDER = FUNCTION MOD (CUNT,3).
IF REMAINDER EQUALS 0
DISPLAY FIZZ
COMPUTE REMAINDER = FUNCTION MOD (CUNT,5)
IF REMAINDER EQUALS 0
DISPLAY BUZZ
COMPUTE REMAINDER = FUNCTION MOD (CUNT,15)
IF REMAINDER EQUALS 0
DISPLAY FIZZ + BUZZ


Only took one uni course like 3 years ago and haven't touched it since. I doubt this will compile because I wrote it on my phone and the alignment will be off aside from other issues.

Forgot the increment... shit

fn main() {
for i in 1..102 {
if i % 15 == 0 { println!("FizzBuzz") }
else if i % 3 == 0 { println!("Fizz") }
else if i % 5 == 0 { println!("Buzz") }
else { println!("{}", i) }
}
}

ok i improved this so now it's actually stable

body{counter-reset: item;list-style-type: none;}
div{counter-increment: item}
div:not(:nth-of-type(3n)):not(:nth-of-type(5n)):before{content: counter(item) ""}
div:nth-of-type(3n):before{content: "Fizz"}
div:nth-of-type(5n):after{content: "Buzz"}
div{font-family: Helvetica; font-weight: 300}
for (var i=0;i

for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i


fite me

>look mom, I posted it again

I'VE PREPARED FOR THIS THREAD IN ADVANCE

Too lazy to rewrite my C version to not do a "% 15" check, so I'm posting the edgy Python version I cooked up with a boolean flag.

for i in range(1,101):
divisorFound = False

if i % 3 == 0:
# Prevent default behavior of automatically printing of newline
print("Fizz", end="")
divisorFound = True
if i % 5 == 0:
print("Buzz", end="")
divisorFound = True
if divisorFound == False:
print(i, end="")

# Print newline after falling through all cases
print("\n", end="")

#include

int main(int i)
{
char *s[] = {"%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n"};

for (i=0; i++ < 100;)
printf(s[!(i % 3) + (!(i % 5) * 2)], i);

return 0;
}

What language is this?

Forgot to mention I indent with only two spaces because I am a masochist

clever use of s.isEmpty(), like it

really fucking clever minimalist approach

fn main() {
for i in 1..101 {
if (i % 3 == 0) && (i % 5 == 0) { println!("FizzBuzz") }
else if i % 3 == 0 { println!("Fizz") }
else if i % 5 == 0 { println!("Buzz") }
else { println!("{}", i) }
}
}

is this good enough to get me a job at google as a diversity officer?

Guess the language

range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


.PHONY: all
all: ; $(info $(fizzbuzz))

fizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzz

web assembly

int n = 0;
bool printed;
while (n < 100)
{
fizzed = false;
if (!(n % 3)) {
printf("Fizz");
}
printed = true;
if (!(n % 5)) {
printf("Buzz");
}
printed = true;
if (!printed) {
printf("%i, ", n);
}
++n;
}
You dun goofed

[...Array(100).keys()].map(function(a){return a+1}).map(function(a){return 0===a%3&&0===a%5?"fizzbuzz":0===a%3?"fizz":0===a%5?"buzz":a})