function dividedByThree(int $number): bool { $rounded = round($number * 0.33, 1); return $rounded != 0 && filter_var($rounded, FILTER_VALIDATE_INT); }
function dividedByThree(int $number): bool{$i = 3;do {if (abs($number) === $i) {return true;}$i += 3;} while (abs($number) >= $i);return false;- function dividedByThree(int $number): bool {
- $rounded = round($number * 0.33, 1);
- return $rounded != 0 && filter_var($rounded, FILTER_VALIDATE_INT);
- }
class MyTestCasesTest extends TestCase { public function testDividedByThree() { $this->assertTrue(dividedByThree(3)); $this->assertTrue(dividedByThree(12)); $this->assertFalse(dividedByThree(13)); $this->assertFalse(dividedByThree(0)); $this->assertTrue(dividedByThree(-12)); } }
class MyTestCases extends TestCase- class MyTestCasesTest extends TestCase
- {
- public function testDividedByThree() {
- $this->assertTrue(dividedByThree(3));
- $this->assertTrue(dividedByThree(12));
- $this->assertFalse(dividedByThree(13));
- $this->assertFalse(dividedByThree(0));
- $this->assertTrue(dividedByThree(-12));
- }
- }