Ad
Code
Diff
  • function dividedByThree(int $number): bool
    {
        while (($number = abs($number)) > 10) {
            $number = array_sum(str_split($number));
        }
        
        return in_array($number, [3,6,9]);
    }
    
    • function dividedByThree(int $number): bool
    • {
    • $abs = abs($number);
    • if($abs < 10){
    • return $abs == 3 || $abs == 6 || $abs == 9;
    • while (($number = abs($number)) > 10) {
    • $number = array_sum(str_split($number));
    • }
    • $sum = array_sum(str_split($abs,1));
    • return dividedByThree($sum);
    • return in_array($number, [3,6,9]);
    • }