Created
March 6, 2012 05:58
-
-
Save revathskumar/1983957 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
for($i=0;$i<=100;$i++){ | |
$str = ""; | |
if($i % 3 ==0) $str = "Fizz"; | |
if($i % 5 ==0) $str .= "Buzz"; | |
if($i % 3 !=0 && $i % 5 != 0) $str = $i; | |
echo $str,"\n"; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(1,101): | |
str = "" | |
if(i % 3 == 0): | |
str = "Fizz" | |
if(i % 5 == 0): | |
str += "Buzz" | |
if(i % 5 != 0 and i % 3 !=0): | |
str = i | |
print str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..100).each do |i| | |
str = "" | |
str = "Fizz" if(i % 3 == 0) | |
str += "Buzz" if(i % 5 == 0) | |
str = i if(i %5 != 0 && i % 3 != 0) | |
p str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment