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

34.29% Correct | 65.71% Incorrect
Last Solution submitted on Nov 25, 2019

Problem Comments

Solution Comments


Problem Recent Solvers153