I need to find whether a number is divisible by 3 without using %, / or *. The hint given was to use atoi() function. Any idea how to do it?
%
/
*
atoi()
Subtract 3 until you either
a) hit 0 - number was divisible by 3
b) get a number less than 0 - number wasn't divisible
-- edited version to fix noted problems
while n > 0: n -= 3 while n < 0: n += 3 return n == 0
1.4m articles
1.4m replys
5 comments
57.0k users