-
-
Save mheijkoop/2509194 to your computer and use it in GitHub Desktop.
Is Number Even
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// this is more the PHP-way | |
// requires the bcmath extension so make sure your shared hosting provider has it. | |
is_even($argv[1]); | |
function is_even($number) { | |
$oldnumber = $number; | |
goto a; | |
result: | |
if ($result) goto noteven; | |
goto notodd; | |
a: | |
$number = bcadd($number, "-1"); | |
$result = !$result; | |
if(bccomp($number, "0") == null) goto result; | |
goto a; | |
notodd: | |
echo "$oldnumber is even"; | |
goto end; | |
noteven: | |
echo "$oldnumber is odd"; | |
end: | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment