FizzBuzz challenge!

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

My solution:

#include

int main(){

int i;

for(i=1; i

Attached: 1548053378526.png (938x1172, 1.33M)

Other urls found in this thread:

blog.codinghorror.com/why-cant-programmers-program/.
github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
instagram.com/jadegrobler/
twitter.com/NSFWRedditVideo

*pats OP on back*
Ya did it

Is this really all there is to programming on Jow Forums?
Copy pasting useless fizz buzzs off google?

I didn't copy paste it.
I just did it from: blog.codinghorror.com/why-cant-programmers-program/.
Why so mad?

I also wrote comments to the program.

Why are programmers such mathlets?

Not mad. Just very unimpressed

Why is it that you fucks start threads with pics like this but when I go to /s/ for faps it's all trash? Am i missing something? Help out a newfag

Attached: 1539470544026.jpg (1280x853, 278K)

>reverse search this pic
>find a bunch of pics of her with her bf
>he's black

Attached: 1549319470323.jpg (320x238, 22K)

who is this cum bum

>Not mad. Just very unimpressed
>Look at me I'm too smart for this.
Go piss up a rope kike.

for n in range(1, 101):
if n % 3 is 0 and n % 5 is 0:
print('fizzbuzz')
elif n % 3 is 0:
print('fizz')
elif n % 5 is 0:
print('buzz')
else:
print(n)


FUCKING HIRE ME

Please hire me too!!! I don't know how to program but I can Kode!!!

#!/bin/sh

for i in $(seq 1 100)
do
if [ $(( i % 15 )) -eq 0 ]
then
echo FizzBuzz
elif [ $(( i % 3 )) -eq 0 ]
then
echo Fizz
elif [ $(( i % 5 )) -eq 0 ]
then
echo Buzz
else echo $i
fi
done

#include

int main(){

for(int i=1, j=1, k=1; i

How is my solution?
I really focused on trying to eliminate magic numbers so employers know I write readable code.

public static final int victimsOfTheGreatLeapForward = 45000000;
public static final int sparrowsKilled = 1000000;
public static final int theGreatFirewall = 65;
public static final int taiwan = 1;
public static final int china = 3;
public static final int winnieThePooh = 2;
public static final int employedAfricans = 0;

public class FreeTibet {
public static void main( String[] theXinjiangUygurAutonomousRegion ) {
for( int democracy = 0; i < victimsOfTheGreatLeapForward/sparrowsKilled + theGreatFirewall; democracy++ ) {
String humanRights = "";
if( (democracy + taiwan) % china == employedAfricans ) {
humanRights += "Fizz";
}
if( (democracy + taiwan) % winnieThePoh == employedAfricans ) {
humanRights += "Buzz"
}
if( humanRights.equals( "" ) ) {
System.out.println( democracy + taiwan );
} else {
System.out.println( humanRights );
}
System.err.out( "动态网自由门 天安門 天安门 法輪功 李洪志 Free Tibet 六四天安門事件 The Tiananmen Square protests of 1989 天安門大屠殺 The Tiananmen Square Massacre 反右派鬥爭 The Anti-Rightist Struggle 大躍進政策 The Great Leap Forward 文化大革命 The Great Proletarian Cultural Revolution 人權 Human Rights 民運 Democratization 自由 Freedom 獨立 Independence 多黨制 Multi-party system 台灣 臺灣 Taiwan Formosa 中華民國 Republic of China 西藏 土伯特 唐古特 Tibet 達賴喇嘛 Dalai Lama 法輪功 Falun Dafa 新疆維吾爾自治區 The Xinjiang Uyghur Autonomous Region 諾貝爾和平獎 Nobel Peace Prize 劉暁波 Liu Xiaobo 民主 言論 思想 反共 反革命 抗議 運動 騷亂 暴亂 騷擾 擾亂 抗暴 平反 維權 示威游行 李洪志 法輪大法 大法弟子 強制斷種 強制堕胎 民族淨化 人體實驗 肅清 胡耀邦 趙紫陽 魏京生 王丹 還政於民 和平演變 激流中國 北京之春 大紀元時報 九評論共産黨 獨裁 專制 壓制 統一 監視 鎮壓 迫害 侵略 掠奪 破壞 拷問 屠殺 活摘器官 誘拐 買賣人口 遊進 走私 毒品 賣淫 春畫 賭博 六合彩 天安門 天安门 法輪功 李洪志 Winnie the Pooh 劉曉波动态网自由门" );
}
}

Some women (actually a lot of women) just want to watch the world burn.
It's fucking ridiculous.

Attached: angry-pepe-gif-9.gif (480x481, 1.65M)

milkies

>Kike
return to your containment board at once young one. And I'll give you a tip for when you turn 18, no one cares if you can check whether the remainder of a quotienr is either one or two

Didn't capitalise, into the bin it goes.

BASED

Made me smile.

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

can you guys please make different threads?
why not "merge sort challenge" or "binary search challenge"?
those are easy too but a step up nonetheless.

OMG what a goddess
I would let her sit on my face all day, she can even piss and shit in my mouth, I'd gladly take it to please my Queen.

(":`('Fizz'"_)`('Buzz'"_)`('FizzBuzz'"_) @. ((0:+:@=5&|)+0:=3&|))"0>:i.99

instagram.com/jadegrobler/
I scrolled for a good 3 minutes and saw no black guys at all. Where the hell did you look? Is this the new form of pol propaganda?

:(

Attached: 1534008085086.jpg (800x800, 40K)

reverse image search is useless. it can show anything or nothing but almost never what you are searching for.

whichfizz = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, n) -> n
end

fizzbuzz = fn (n) ->
whichfizz.(rem(n, 3), rem(n, 5), n)
end

IO.inspect Enum.map(1..100, fizzbuzz)

black hair = nigger

Attached: Screenshot_2019-02-08_22-33-16.png (595x589, 409K)

t. nordcuck

Attached: 1494275691236.jpg (633x568, 163K)

even her dog is black

Kek

#include

/*
* Author: user
* It's a fizzbuzz
* ^_^
*/


/* Today we'll be conjuring the spirits of the computer with our spells
* This function returns an int.
* it literally fucking says it right there
* you really should know what an integer is
*/
int main()
{
int i;

/* do a dumb loop */
for(i=1; i < 101; i++) {

/*Here we find the percentage of i in 3 */
if(i % 3 == 0)
printf("Fizz");
/* I understand it's complicated */
if( i % 5 == 0)
printf("Buzz");
/* Have you ever used this percentage operator before? */
if((i%5 != 0) && (i%3!=0))
printf("%d", i);

printf("\n");
}

/* Literally just return 0 */
if(i=101){
return 0;
}

else {
/* else return 5 cuz I'm so random :D */
return 5;
}
}

static void Main(string[] args)
{
Func[] values = {i => i + "", i => "Fizz", i => "Buzz", i => "FizzBuzz"};
var fizzBuzz = Enumerable.Repeat(0, 100)
.Select((x, i) => x + Math.Sin(3886233.05311717 * i + 3886234.09321357))
.Select((x, i) => x + Math.Sin(3319323.02253289 * i + 3319324.77764699))
.Select((x, i) => x + Math.Sin(517102.382386617 * i + 517104.106333962))
.Select((x, i) => 0.7 * x + 1.2)
.Select((x, i) => values[(int) x](i + 1));
Console.WriteLine(String.Join("\n", fizzBuzz));
Console.ReadKey();
}

zhg123403-com.webnode.com/

no shit you're going find mostly trash on /s/. It's filled with old who love to post their flat-assed, flabby wives.

Attached: 0f7099333334a7e4ffc6d518b11f91eab87bf5a28d13d7f1b5fb574596a6b0b6.jpg (600x600, 37K)

this but unironically

rate

Attached: fizzbuzz.png (804x4106, 297K)

bump

wtf that guy is like a 9 and that girl is a barely a 5
incel uprising when?

#include
int main(){
char fizzbuzz[]="fizzbuzz";
for (int i=0;i

bet you can't beat this

```
#![no_std]
#![feature(asm, lang_items, libc, no_std, start)]

extern crate libc;

const LEN: usize = 413;
static OUT: [u8; LEN] = *b"\
1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n\
16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n\
31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n\
46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n\
61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n\
76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n\
91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz\n";

#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
unsafe {
asm!(
"
mov $$1, %rax
mov $$1, %rdi
mov $0, %rsi
mov $1, %rdx
syscall
"
:
: "r" (&OUT[0]) "r" (LEN)
: "rax", "rdi", "rsi", "rdx"
:
);
}
0
}

#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] extern fn panic_fmt() {}
```

for i in range(1, 20):
n=""
if i%3==0:
n+="Fizz"
if i%5==0:
n+="Buzz"
if n != "":
n+="!"
print(n)
else:
print(i)

for num in range(1,21):
if num % 3 == 0 and num % 5 == 0:
print('FizzBuzz')
elif num % 3 == 0:
print('Fizz')
elif num % 5 == 0:
print('Buzz')
else:
print(num)

How's This
for n in range(1, 101):
s = ""
p = False
if n % 3 == 0:
s += "Fizz"
p = True
if n % 5 == 0:
s += "Buzz"
p = True
if p:
print(s)
else:
print(n)

wait shit user said 100 yeah change my num range to be (1,101)

Are you just gay or are your standards for women really that high?

going to go for yes on both counts for this titmouse. Incels are all closet cases who project their sexual confusion as high standards

for s in map((lambda x:
"Fizz"*(x % 3 == 0) +
"Buzz"*(x % 5 == 0) +
str(x)*(x % 3 != 0 and x % 5 != 0)), range(1, 101)):
print s

based and redpilled

1..100(%3, %5, i):
"fizz", "buzz", i

Attached: impressive.gif (350x255, 1.78M)

oooooofff nice

There are more efficient ways to use FP to solve this

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

Attached: 1548375448251.jpg (360x360, 47K)

do your own homework, dude. you think your prof doesn't have anti-cheating software to find you out?
besides which, you ain't gonna learn shit if you get other people to do your work...

>caring about FP or efficiency in python
It's just a curious way to do fizzbuzz in python due to how it handles string expressions.
Here's a cute Haskell fizzbuzz.
replaceWhat = map show [1..]

replaceWith = zipWith (++) (cycle ["", "", "Fizz"]) (cycle ["", "", "", "", "Buzz"])

fizzbuzz = zipWith max replaceWhat replaceWith

main = mapM_ putStrLn (take 100 fizzbuzz)

Why not just use a guard?

Who else took a cs class and had to quit after their assignments included questions like "write application x in Java using only if statements and print"

Best I've seen:

#include


int main(void) {

char *fizzbuzz[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};

for (int i = 1; i

>Write a program that prints the numbers from 1 to 100
>Stop at 19

Can't follow directions to deliver the product as specified. 0/10 would not hire

didn't hardcode it in assembly with direct syscalls 0.5/10

How does she have such robust ass and thighs but stumps for calves?

beat this, asshole

Attached: 1508431457709.gif (585x454, 2.13M)

(defun fizzbuzz()
(setq iter 1)
(while (< iter 101)
(if (equal (% iter 3) 0) (princ "fizz"))
(if (equal (% iter 5) 0) (princ "buzz"))
(if (and (not (equal (% iter 3) 0)) (not (equal (% iter 5) 0))) (princ iter))
(setq iter (+ iter 1))))
(fizzbuzz)

t.

Attached: 1539462987975s.jpg (125x125, 3K)

obs x86 linux asm gets the fucc
;
fizzBuzz:
mov r10, rax
mov r15, 0 ; boolean fizz or buzz
checkFizz:
xor rdx, rdx ; clear rdx for division
mov rbx, 3
div rbx
cmp rdx, 0 ; modulo result here
jne checkBuzz
mov r15, 1
mov rsi, fizz
mov rdx, 4
mov rax, 1
mov rdi, 1
syscall
checkBuzz:
mov rax, r10
xor rdx, rdx
mov rbx, 5
div rbx
cmp rdx, 0
jne finishLine
mov r15, 1
mov rsi, buzz
mov rdx, 4
mov rax, 1
mov rdi, 1
syscall
finishLine: ; print number if no fizz or buzz
cmp r15, 1
je nextLine
mov rax, r10
call printNum
ret
nextLine:
mov rsi, newLine
mov rdx, 1
mov rax, 1
mov rdi, 1
syscall
ret

printNum: ; write proper digits into number buffer
cmp rax, 100
jl lessThanHundred
mov byte [number], 49
mov byte [number + 1], 48
mov byte [number + 2], 48
mov rdx, 3
jmp print

lessThanHundred: ; get digits to write through division
xor rdx, rdx
mov rbx, 10
div rbx
add rdx, 48
cmp rax, 0
je lessThanTen
add rax, 48
mov byte [number], al
mov byte [number + 1], dl
mov rdx, 2
jmp print

lessThanTen:
mov byte [number], dl
mov rdx, 1
print:
mov byte [number + rdx], 10 ; add newline
inc rdx
mov rax, 1
mov rdi, 1
mov rsi, number
syscall
ret

Attached: OS_USA.jpg (3024x4032, 2.12M)

Google Images has been total trash lately.

OP, we need relevant posts here.

>>Write a program that prints the numbers from 1 to 100. But for multiples of three print "Semen" instead of the number and for the multiples of five print "Demon". For numbers which are multiples of both three and five print "SemenDemon".

Attached: google images.png (1272x548, 101K)

x86 linus asm can run on any modern CPU. I don't have to waste my time w/ fabs when all I have to do is pay some shekels to Intel's israel fab up and running

Attached: oof.jpg (1078x1125, 266K)

I wonder if Google fudged their image search intentionally towards not even mildly sexy? It's really hard to miss that girl's account.

Try Yandex or something next time.

IG jadegrobler.

python is the most powerful programming language

Attached: fizzbuzz.png (340x255, 5K)

Good to know that anglos, Spaniards, and southern Europeans are niggers. You know, the europoors that actually did something in the world while nordniggers did nothing but destroy.

def semendemon(n): # Because not writing functions with parameters is dumb.
for i in range (1, n+1):
print("Semen"*(i%3==0) + "Demon"*(i%5==0) or i)

semendemon(100)

Truly.

lol this is gold

func fizzBuzz(to limit: Int) {
for i in 1...limit {
switch (i % 3, i % 5) {
case (0, 0): print("FizzBuzz")
case (0, 1...): print("Fizz")
case (1..., 0): print("Buzz")
default: print("\(i)")
}
}
}

fizzBuzz(to: 100)

Please, tell me it's just an implants.

for i in range(1, 101, 1):
if i % 5 == 0 and i % 3 == 0:
print('FizzBuzz')
elif i % 3 == 0:
print('Fizz')
elif i % 5 ==
0:
print('Buzz')
else:
print(i)

div5(X) :- 0 is X mod 5.
div3(X) :- 0 is X mod 3.

fizzbuzz(X, Max) :- (div3(X), div5(X), writeln('FizzBuzz');
div5(X), writeln('Buzz');
div3(X), writeln('Fizz');
writeln(X)), !,
X < Max,
X1 is X+1,
fizzbuzz(X1, Max).

fizzbuzz :- fizzbuzz(1, 100).

Bump

you misspelled "studio" in the include

FUCK. That caught me off guard.

I love you, my goddess

Why not initialise a with i's value?

def fizz(x):
if x %3 == 0:
return "fizz"
return ""
def buzz(x):
if x%5 == 0:
return "buzz"
return ""
def concatonation(x,y):
return x+y
def increase(x):
return x + 1
def less_than_one_hundred(x):
if (x < 100):
return True
return False
def printing(x):
return concatonation(fizz(x),buzz(x)) or x
def fizz_buzz(x):
print(printing(x))
if (less_than_one_hundred(x)):
fizz_buzz(increase(x))
fizz_buzz(1)

Attached: 1542048078706.png (839x809, 832K)

>concatonation

Heres a terse haskell fizzbuzz
import System.IO

fizzbuzz ints strs int = check $ foldr ( ++ ) "" $ zipWith (testInt) ints strs
where
testInt i s
| mod int i == 0 = s
| otherwise = ""
check str
| null str = show int
| otherwise = str


main = sequence $ map (print . (fizzbuzz [3,5] ["Fizz","Buzz"])) [1..100]

1. UK
2. France
3. Germany
If you take away "French" inventors like Charles Frédéric Gerhardt, Germany would be second. What's your point?

Attached: hire me.png (303x193, 6K)

Heres the semen demon challenge in ruby for people who like code that is unreadable and on one line
puts (1..100).map{|i|s='';{3=>'Semen',5=>'Demon'}.each{|k,v|s

for x in range(1,101):
print( "FizzBuzz"[4*(2-(x-1)%3+x%3)//3:4*(6+(x-1)%5-x%5)//5] or x)

for x in range(1,101):
print( "FizzBuzz"[4*(2-(x-1)%3+x%3)//3:4*(6+(x-1)%5-x%5)//5] or x)

Using only recursion and switch statements
static void FizzBuzz1(int f,int b,int c){
switch(c){
case 100:
return;
default:
switch(f){
case 2:
System.out.print("Fizz");
switch(b){
case 4:
System.out.println("Buzz");
FizzBuzz1(0,0,c+1);
break;
default:
System.out.println();
FizzBuzz1(0,b+1,c+1);
break;
}
break;
case 0:
case 1:
switch(b){
case 4:
System.out.println("Buzz");
FizzBuzz1(f+1,0,c+1);
break;
default:
System.out.println(c);
FizzBuzz1(f+1,b+1,c+1);
}
}
}
}

public static void main(String[] args) {
FizzBuzz1(0,0,1);
}

Very creative! I understand that you're computing the string index for your output. But beyond that i'm confused. I've never seen a colon used like that in python.

Nice supermeme, this is the only reason i browse this site

This doesn't use the modular operator so is way faster:

x, y = 0, 0

for i in range(100):
if x >= 3 and y >= 5:
x = 0
print("FizzBuzz")
elif x >= 3:
x = 0
print("Fizz")
elif y >= 5:
y = 0
print("Buzz")
else:
print(i)

x+=1
y+=1

Typoed this shit:

x, y = 0, 0

for i in range(100):
if x >= 3 and y >= 5:
x = 0
y = 0
print("FizzBuzz")
elif x >= 3:
x = 0
print("Fizz")
elif y >= 5:
y = 0
print("Buzz")
else:
print(i)

x+=1
y+=1

say "Fizz"x!($_%3)."Buzz"x!($_%5) || $_ for (1..100)

glorious perl one-liner coming through

Can I use Parallel.For()?

I did some of it!


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
class Program
{
static void Main()
{
IEnumerable range = Enumerable.Range(0, 10000000).ToArray();
Parallel.ForEach(range, () => 0, (j, loop, total) => {
if ((j % 3 == 0) && (j % 5 == 0))
{
total += 1;
}
return total;
},(localFinally)=>
{
Console.WriteLine(localFinally.ToString());
});
Console.ReadKey();
}
}