I have to do a function that tests divisibility by 3, return% with% if it is divisible by 3. Otherwise return% with%. Following the rule: A number is divisible by 3 when the sum of its digits is divisible by three.
I have the following variables:
int dividendo;
int divisor;
And I have the following function:
int divisibilidade3(int num);
I need to separate the digits of the true
variable, for example, when the user enters the false
splitter I will call the dividendo
function and check if the final digit ends with 3, 6 or 9.
For example, if the user enters the number 3
, I need to break this number into parts, then: divisibilidade3
, as is 25848
the final result, then it is divisible by 3. p>
The function should repeat the process of summation of digits of the results obtained until the sum is a one-digit number. If this digit is equal to 3, 6, or 9, so the original number is divisible by 3.
I will have to follow all these rules using the divisibility criteria. If anyone can help me, I'm grateful.