Skip to content

Instantly share code, notes, and snippets.

@glabra
Created December 26, 2017 11:07
Show Gist options
  • Save glabra/d60c178735ac849002d15647d4fb87a3 to your computer and use it in GitHub Desktop.
Save glabra/d60c178735ac849002d15647d4fb87a3 to your computer and use it in GitHub Desktop.
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