-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added FizzBuzz program (and a few languages - too busy to add more)
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# FizzBuzz | ||
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". |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
public Class FizzBuzz { | ||
public static void main(String[] args) { | ||
for(int i = 1; i <= 100; i++) { | ||
if((i % 5 == 0) && (i % 3 == 0)) { | ||
System.out.println("FizzBuzz"); | ||
} else if(i % 3 == 0) { | ||
System.out.println("Fizz"); | ||
} else if(i % 5 == 0) { | ||
System.out.println("Buzz"); | ||
} else { | ||
System.out.println(i); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
for($i = 1; $i <= 100; $i++) { | ||
if(($i % 5 == 0) && ($i % 3 == 0)) { | ||
echo "FizzBuzz" . "\n"; | ||
} elseif($i % 3 == 0) { | ||
echo "Fizz" . "\n"; | ||
} elseif($i % 5 == 0) { | ||
echo "Buzz" . "\n"; | ||
} else { | ||
echo $i . "\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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python | ||
|
||
for i in range(1, 101): | ||
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 | ||
|