Skip to content

Commit

Permalink
Time: 18 ms (6.86%), Space: 21 MB (59.31%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
joseantoniochacon committed Jun 1, 2024
1 parent 3ef8224 commit 4781a4c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 0412-fizz-buzz/0412-fizz-buzz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {

/**
* @param Integer $n
* @return String[]
*/
function fizzBuzz($n) {
$fizzBuzz = array();
for($i = 1; $i <= $n; $i++){
if($i%3 == 0 && $i%5 == 0){
$fizzBuzz[] = 'FizzBuzz';
}else if($i%3 == 0){
$fizzBuzz[] = 'Fizz';
}else if($i%5 == 0){
$fizzBuzz[] = 'Buzz';
}else{
$fizzBuzz[] = strval($i);
}
}
return $fizzBuzz;
}
}

0 comments on commit 4781a4c

Please sign in to comment.