Skip to content

Commit

Permalink
Added FizzBuzz program (and a few languages - too busy to add more)
Browse files Browse the repository at this point in the history
  • Loading branch information
Macha authored and Simon committed Jan 19, 2010
1 parent d7377ce commit 5586381
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FizzBuzz/README.mkd
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".
15 changes: 15 additions & 0 deletions FizzBuzz/fizzbuzz.java
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);
}
}
}
}
13 changes: 13 additions & 0 deletions FizzBuzz/fizzbuzz.php
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";
}
}
?>
12 changes: 12 additions & 0 deletions FizzBuzz/fizzbuzz.py
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

0 comments on commit 5586381

Please sign in to comment.