Skip to content

Instantly share code, notes, and snippets.

@joduplessis
Created September 4, 2017 19:42
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 joduplessis/4a7d0d9f682a3b216c1bb2c6a1efe048 to your computer and use it in GitHub Desktop.
Save joduplessis/4a7d0d9f682a3b216c1bb2c6a1efe048 to your computer and use it in GitHub Desktop.
The very famous sequenced printout test people like to ask for when interviewing junior devs.
<?php
for ( $x=1 ; $x<=100 ; $x++ ) {
if ( ( fmod($x,3) == 0 ) && ( fmod($x,7) == 0 ) ) {
echo "<span style='color:#ff0000'>Both</span><br/>" ;
} else if ( fmod($x,3) == 0 ) {
echo "<span style='color:#00ff00'>Three</span><br/>" ;
} else if ( fmod($x,7) == 0 ) {
echo "<span style='color:#0000ff'>Seven</span><br/>" ;
} else {
echo $x . "<br/>" ;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment