Created
December 26, 2017 11:07
-
-
Save glabra/d60c178735ac849002d15647d4fb87a3 to your computer and use it in GitHub Desktop.
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
function is_zeroleading($n) { | |
// 三桁以上の数字で、最大の桁以外が0だった場合、キリ番とする | |
do { | |
if ($n % 10 !== 0) | |
return false; | |
} while (($n /= 10) >= 10); | |
return true; | |
} | |
function is_sequential($n) { | |
// 同じ数字の連続 | |
do { | |
$tail = $n % 10; | |
$n /= 10; | |
if ($tail !== $n % 10) | |
return false; | |
} while ($n > 10); | |
return true; | |
} | |
function is_kiriban($number) { | |
if (KIRIBAN_THRESHOLD > $number) { | |
return false; | |
} | |
if (is_zeroleading($number) || | |
is_sequential($number)) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment