- abs: documentation ( source)
- printf: documentation ( source)
<?php
function is_even(int $n): bool {
$fn = null;
$fn = fn(int $nr, bool $not): bool => $nr === 0 ? !$not : $fn(($nr < 0 ? abs($nr) : $nr) - 1, !$not);
return $fn($n, false);
}
for($i = -5; $i <= 12; $i++) {
printf('is %d even? %s.%s', $i, is_even($i) ? 'yes': 'no', "\n");
}