Ad
Code
Diff
  • function dividedByThree(int $number): bool
    {
        return $number !== 0 && !(bool) base_convert($number, 10, 3)[-1];
    }
    
    • function dividedByThree(int $number): bool
    • {
    • while (($number = abs($number)) > 10) {
    • $number = array_sum(str_split($number));
    • }
    • return in_array($number, [3,6,9]);
    • return $number !== 0 && !(bool) base_convert($number, 10, 3)[-1];
    • }