Jump to content

Fizzbuzz

babbaj

scary link is scary

Case: NZXT Phantom PSU: EVGA G2 650w Motherboard: Asus Z97-Pro (Wifi-AC) CPU: 4690K @4.2ghz/1.2V Cooler: Noctua NH-D15 Ram: Kingston HyperX FURY 16GB 1866mhz GPU: Gigabyte G1 GTX970 Storage: (2x) WD Caviar Blue 1TB, Crucial MX100 256GB SSD, Samsung 840 SSD Wifi: TP Link WDN4800

 

Donkeys are love, Donkeys are life.                    "No answer means no problem!" - Luke 2015

 

Link to comment
Share on other sites

Link to post
Share on other sites

i'm too stupid for this.

My PC

[ I5 4690k (no oc) - Gigabyte Z97 D3H - 8GB Ram - Sapphire R9 280X Vapor-X ]

Link to comment
Share on other sites

Link to post
Share on other sites

i'm too stupid for this.

dude.... our systems are like... brothers o-o

Case: NZXT Phantom PSU: EVGA G2 650w Motherboard: Asus Z97-Pro (Wifi-AC) CPU: 4690K @4.2ghz/1.2V Cooler: Noctua NH-D15 Ram: Kingston HyperX FURY 16GB 1866mhz GPU: Gigabyte G1 GTX970 Storage: (2x) WD Caviar Blue 1TB, Crucial MX100 256GB SSD, Samsung 840 SSD Wifi: TP Link WDN4800

 

Donkeys are love, Donkeys are life.                    "No answer means no problem!" - Luke 2015

 

Link to comment
Share on other sites

Link to post
Share on other sites

dude.... our systems are like... brothers o-o

o_o woah, you have good taste.

My PC

[ I5 4690k (no oc) - Gigabyte Z97 D3H - 8GB Ram - Sapphire R9 280X Vapor-X ]

Link to comment
Share on other sites

Link to post
Share on other sites

for ($i=1; $i <= 100; $i++) {	$bool = true;	if($i % 3 == 0){		echo "Fizz";		$bool = false;	}	if($i % 5 == 0){		echo "Buzz";		$bool = false;	}	if($bool)		echo $i;	echo "\r\n";} 

I'd do something like this in php, I can understand why some people wouldn't be able to come up with a solution though.

// TODO: Update signature to include PC buid.

Link to comment
Share on other sites

Link to post
Share on other sites

Why no "elseif" statements? 

 

Edit: My bad, I see what you were going for now...

 

Haha, you see the trick I did ;P Eliminating an if-statement :)

// TODO: Update signature to include PC buid.

Link to comment
Share on other sites

Link to post
Share on other sites

It'll do the job but I'd say it'd still be better using elseif's to make it more readable.  :P

 

True true, but the challenge was as short as possible ;P

// TODO: Update signature to include PC buid.

Link to comment
Share on other sites

Link to post
Share on other sites

I think you'll find that if you count the lines in the elseif version excluding the comments it's shorter than the non-elseif version though.  ;)

 

 

I guess you are right, especially if you do it this way:

for ($i=1; $i <= 100 ; $i++) { 	if($i % 15 == 0)     echo "FizzBuzz\r\n";	elseif ($i % 3 == 0) echo "Fizz\r\n";	elseif ($i % 5 == 0) echo "Buzz\r\n";	else                 echo $i . "\r\n";}

// TODO: Update signature to include PC buid.

Link to comment
Share on other sites

Link to post
Share on other sites

Not really a repost, but we already had a lot of FizzBuzz contributions here on this forum

 

______________________________________

public class Fizzy {    public static void main (String [] args){        for(int i=1;i<=100;i++)System.out.println((i%3==0?"Fizz":"")+(i%5==0?"Buzz":"")+(i%3==0||i%5==0?"":i));    }}

or if you lose the whitespaces / linebreaks like Avratz ...

public class Fizzy{public static void main(String [] args){for(int i=1;i<=100;i++)System.out.println((i%3==0?"Fizz":"")+(i%5==0?"Buzz":"")+(i%3==0||i%5==0?"":i));}}

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×