Skip to content

Instantly share code, notes, and snippets.

@lucas-marciano
Last active July 12, 2017 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucas-marciano/c2b77b2c8517bbac89f64659dcc08b08 to your computer and use it in GitHub Desktop.
Save lucas-marciano/c2b77b2c8517bbac89f64659dcc08b08 to your computer and use it in GitHub Desktop.
<?php
for ($i = 1; $i <= 100; $i++){
if(divisorCinco($i) && divisorTres($i)){
echo "<p>FizzBuzz</p>";
}elseif (divisorCinco($i)){
echo "<p>Buzz</p>";
}elseif(divisorTres($i)){
echo "<p>Fizz</p>";
}else{
echo "<p>{$i}</p>";
}
}
public function divisorCinco($num)
{
return $num % 5 == 0 ||$num % 5 == 5;
}
public function divisorTres($num)
{
return $num % 3 == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment