dividedByThree = (n) => (n - (n % 3)) * 0.3333333333333333;
def dividedByThree(number):if number == 0:return Falsereturn abs(number) % 3 == 0- dividedByThree = (n) => (n - (n % 3)) * 0.3333333333333333;
// basic cases Test.assertEquals(dividedByThree(3), 1) Test.assertEquals(dividedByThree(12), 4) Test.assertEquals(dividedByThree(13), 4) Test.assertEquals(dividedByThree(0), 0) Test.assertEquals(dividedByThree(-12), -4) Test.assertEquals(dividedByThree(10013), 3337) // catch iterative subtraction in timing Test.assertEquals(dividedByThree(1234567890), 411522630) Test.assertEquals(dividedByThree(9876543210), 3292181070) Test.assertEquals(dividedByThree(5611809), 1870603)
Test.assert_equals(dividedByThree(3),True)Test.assert_equals(dividedByThree(12),True)Test.assert_equals(dividedByThree(13),False)Test.assert_equals(dividedByThree(0),False)Test.assert_equals(dividedByThree(-12),True)- // basic cases
- Test.assertEquals(dividedByThree(3), 1)
- Test.assertEquals(dividedByThree(12), 4)
- Test.assertEquals(dividedByThree(13), 4)
- Test.assertEquals(dividedByThree(0), 0)
- Test.assertEquals(dividedByThree(-12), -4)
- Test.assertEquals(dividedByThree(10013), 3337)
- // catch iterative subtraction in timing
- Test.assertEquals(dividedByThree(1234567890), 411522630)
- Test.assertEquals(dividedByThree(9876543210), 3292181070)
- Test.assertEquals(dividedByThree(5611809), 1870603)