Ad
Code
Diff
  • function dividedByThree(int $number): bool
    {
        return (3 == $number = abs($number)) ? true : (($number < 6) ? false : in_array($number, range(3, $number, 3)));
    }
    
    • function dividedByThree(int $number): bool
    • {
    • $i = 3;
    • do {
    • if (abs($number) === $i) {
    • return true;
    • }
    • $i += 3;
    • } while (abs($number) >= $i);
    • return false;
    • return (3 == $number = abs($number)) ? true : (($number < 6) ? false : in_array($number, range(3, $number, 3)));
    • }