My solution to FizzBuzz

Started programming 45 minutes ago. I didn't know anything before starting

#include

main()
{

int i;

for (i = 1; i

Attached: 1535234637801.png (1600x857, 260K)

Other urls found in this thread:

pastebin.com/EKN8dNbP
blog.codinghorror.com/why-cant-programmers-program/
pastebin.com/keg5QsKA
twitter.com/NSFWRedditGif

nice blog I rate your solution *it works*/10

stop drinking if you dont drink then start

It works. It isn't particularly spectacular but it does the required job.

It's not a matter if you can do fizzbuzz or not; it's a matter of how many ways you can do fizzbuzz

#include

int main() {
int i;
for (i=0;i

Ah fuck my phone ate a "

Waiting for pacstrap...

OP here. I just looked at the first 5 lines. If you're not writing in ANSI C you can declare i in the for loop.

Never had a job interview or something, but looks fine too me

Doesn't work as required. Always prints the value of i.

Now OP do fizzbuzz without using modulos. This is still supposed to be piss-easy.

Bloated feature creep

#include
#include

bool isFizzBuzz(int i){
if (i % 15 == 0) {
return true;
} else return false;
}

bool isBuzz(int i){
if (i % 5 == 0) {
return true;
} else return false;
}

bool isFizz(int i){
if (i % 3 == 0) {
return true;
} else return false;
}

int main(){
for (int i = 0; i

Same here user, except I spent 25 minutes instead.

#include
int main() {
int current = 0;
while(current < 101) {
current = current + 1;
if(current % 3 == 0 && current % 5 == 0) {
printf("FizzBuzz");
printf("\n");
continue;
}
else if(current % 3 == 0) {
printf("Fizz");
printf("\n");
continue;
}
else if(current % 5 == 0) {
printf("Buzz");
printf("\n");
continue;
}
else {
printf("%d", current);
printf("\n");
continue;
}
}
}

now write a recursive fizzbuzz

What?

see

Are you a wizard?

How do I format as code?


package main

import "fmt"

func fizzBuzz(n, max int) {
if n%(3*5) == 0 {
fmt.Println("FizzBuzz")
} else if n%3 == 0 {
fmt.Println("Fizz")
} else if n%5 == 0 {
fmt.Println("Buzz")
} else {
fmt.Println(n)
}

if n+1 == max {
return
}
fizzBuzz(n+1, max)
}

func main() {
fizzBuzz(1, 17)
}

holy shit what is this sorcery

b-b-b-based!

holy shit

Attached: 1544569267059.png (286x356, 108K)

package main

import "fmt"

func fizzBuzz(n, max int) {
if n%(3*5) == 0 {
fmt.Println("FizzBuzz")
} else if n%3 == 0 {
fmt.Println("Fizz")
} else if n%5 == 0 {
fmt.Println("Buzz")
} else {
fmt.Println(n)
}

if n+1 == max {
return
}
fizzBuzz(n+1, max)
}

func main() {
fizzBuzz(1, 17)
}

#include

int main()
{
for(int i = 1; i < 100; ++i)
std::cout

let _ = (1...100).forEach {
switch ($0 % 3, $0 % 5) {
case (0, 0): print("FizzBuzz")
case (0, 1...): print("Fizz")
case (1..., 0): print("Buzz")
default: print("\($0)")
}
}

woah...
what language is this?

#!/bin/bash

for i in {1..100}
do
if [[ 0 -eq "($i%5) + ($i%3)" ]]; then
echo "FizzBuzz"
elif [[ 0 -eq "($i%3)" ]]; then
echo "Fizz"
elif [[ 0 -eq "($i%5)" ]]; then
echo "Buzz"
else
echo $i
fi
done

Swift

pastebin.com/EKN8dNbP
A version of fizzbuzz I wrote for a class.

Attached: fizzbuzz.jpg (491x648, 80K)

You can put the \n after printing Fizz or Bus, no need for 2 prints.
>continue;
why?

fizzBuzz :: Int -> String
fizzBuzz x
| x `mod` 15 == 0 = "FizzBuzz"
| x `mod` 3 == 0 = "Fizz"
| x `mod` 5 == 0 = "Buzz"
| otherwise = show x

main = mapM_ putStrLn [fizzBuzz x | x

my nigga

Attached: 1535879393192.jpg (450x425, 155K)

Did this just happen in my thread?

Attached: 36153699095_eb5fea8f65_c.jpg (800x548, 137K)

Better than 99.5% of all programming job applicants.

#include

int main(){
for(int i = 0; i

Your shithole country is not representative of typical programming applicants.

you better be joking, sir. i reject anyone who does this.

Even Pajeets can solve this and feel smart, stop

1 in 200 is the correct statistic though

blog.codinghorror.com/why-cant-programmers-program/

Attached: 1553094787070s.jpg (249x238, 10K)

I think this has a lot to do with how being a 'good' programmer means introducing 50 lambdas into your code and making the syntax as short and compact as possible, rather than just finding an answer and then focusing on optimization. Programming is also a lot more than algorithms but that gets shoved under the rug and leads to retarded organization and poor grasp of OOP(the right way to program)

Move aside brainlet
#include

int main(){
for(int i = 0; i

how. You won user

AAAAAAAAAAAAAAAAA

Holy shit, the context just makes it better.

Based as FUCK

Attached: 30s.png (380x482, 166K)

function fizzbuzz(i, max){
if(i > max) return true;
if(i % 3 == 0 && i % 5 == 0) console.log('fizzbuzz');
else if(i % 3 == 0) console.log('fizz');
else if(i % 5 == 0) console.log('buzz');
else console.log(i);
return fizzbuzz(i+1, max);
}

here's a shitty attempt at a recursive js fizzbuzz sir

def helpMe(x):
lol = ["", "", 'fizz', "", 'buzz', 'fizz', "", "", 'fizz', 'buzz', "", 'fizz', "", "", 'fizzbuzz']
if lol[(x-1)%15] == "":
return str(x)
return lol[(x-1)%15]

print(' '.join(list(map(helpMe,list(range(1, 100))))))

made it way better :)
/**
* Checks if a number should print fizz, buzz, fizzbuzz or itself
* @param {int} a the number to be checked
* @return what the number should print
*/
function fizzOrBuzz(a){
var result = (a%3?'':'fizz')+(a%5?'':'buzz');
return(result?result:a);
}

/**
* Recursively checks every number from i to max and prints a proper fizzbuzz
* @param {int} i current number
* @param {int} max maximum number to check
* @return returns the next iteration or true if i exceeds the maximum value
*/
function fizzbuzz(i, max){
if(i > max) return true;
console.log(fizzOrBuzz(i));
return fizzbuzz(i+1, max);
}

// prints a proper fizzbuzz for numbers between 1 and 100
fizzbuzz(1, 100);

IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZ-BUZZ.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CT PIC 999 VALUE 1.
01 FZ PIC 999 VALUE 1.
01 BZ PIC 999 VALUE 1.
PROCEDURE DIVISION.
FIZZ-BUZZ-MAIN SECTION.
PERFORM 100 TIMES
IF FZ = 3
THEN IF BZ = 5
THEN DISPLAY "FizzBuzz"
COMPUTE BZ = 0
ELSE DISPLAY "Fizz"
END-IF
COMPUTE FZ = 0
ELSE IF BZ = 5
THEN DISPLAY "Buzz"
COMPUTE BZ = 0
ELSE
DISPLAY CT
END-IF
END-IF
ADD 1 TO CT
ADD 1 TO FZ
ADD 1 TO BZ
END-PERFORM
STOP RUN.

Got the dubs too. A true hero of the Chins.

Outta my way, unemployed shits. Let me show you how a well-paid Delphi dev does it.

pastebin.com/keg5QsKA

Attached: me.jpg (1080x1331, 97K)

You're hired, when can you start?

That depends, how much are you willing to pay on top of the 500k salary I expect?

OH FUCK