Cody

Problem 42405. Divisible by 3

Pursuant to the first problem in this series, this one involves checking for divisibility by 3.

Write a function to determine if a number is divisible by 3. This can be checked by at least two different methods:

  1. Sum the digits in the number. If the resulting sum is divisible by 3, then so is the original number. This routine can be applied recursively until the resulting sum is a single digit.
  2. From the wikipedia reference page: "Subtract the quantity of the digits 2, 5, and 8 in the number from the quantity of the digits 1, 4, and 7 in the number." If the resulting sum (absolute value) is a multiple of 3, then so is the original number.

Previous problem: divisible by 2. Next problem: divisible by 4.

Solution Stats

36.2% Correct | 63.8% Incorrect
Last solution submitted on Aug 16, 2019

Problem Comments

Solution Comments

Recent Solvers140

Suggested Problems

More from this Author161