Skip to content

Commit dfcd93d

Browse files
authored
Merge pull request #30 from kamil200/main
fizz buzz implementation in PHP
2 parents 8a95e8e + 2dc4898 commit dfcd93d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

PHP/fizzbuzz.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
// PHP program to print Fizz Buzz
3+
4+
$i;
5+
for ($i = 1; $i <= 100; $i++)
6+
{
7+
// number divisible by 3 and
8+
// 5 will always be divisible
9+
// by 15, print 'FizzBuzz' in
10+
// place of the number
11+
if ($i % 15 == 0)
12+
echo "FizzBuzz" . " ";
13+
14+
// number divisible by 3? print
15+
// 'Fizz' in place of the number
16+
else if (($i % 3) == 0)
17+
echo "Fizz" . " ";
18+
19+
// number divisible by 5, print
20+
// 'Buzz' in place of the number
21+
else if (($i % 5) == 0)
22+
echo "Buzz" . " ";
23+
24+
else // print the number
25+
echo $i," " ;
26+
}
27+
28+
// This code is contributed by m_kit
29+
?>

0 commit comments

Comments
 (0)