Problem 42510. Divisible by n, Composite Divisors
Pursuant to Divisible by n, prime vs. composite divisors, this problem requires you to write a function that determines divisibility for a large number (n_str) when the divisor is a composite. As was required in that problem, you will need to formulate the highestpower factorization of the divisor. Divisibility of n_str can then be determined by testing against each highestpower factor. For simplicity, this problem is restricted to numbers that contain the following as highestpower factors: 2, 3, 4, 5, 8, 9, and 10, as these divisibility tests are trivial. Their rules are included briefly below, for reference.
As an example, a number is divisible by 30 if it is divisible by 2, 3, and 5, as those are the highestpower factors for 30. Likewise, a number is divisible by 36 if it is divisible by 4 and 9 (not 3), as those are its highestpower factors.
The only restriction that remains is Java.
 Divisible by 2: if the last digit is divisible by 2.
 Divisible by 3: if the sum of the number's digits (n_str) is divisible by 3. Apply iteratively, as necessary, to arrive at a singledigit number.
 Divisible by 4: if the last two digits are divisible by 4.
 Divisible by 5: if the last digit is a 0 or 5.
 Divisible by 8: if the last three digits are divisible by 8.
 Divisible by 9: if the sum of the number's digits (n_str) is divisible by 9. Apply iteratively, as necessary, to arrive at a singledigit number.
 Divisible by 10: if the last digit is zero.
Previous problem: Divisible by n, Truncatednumber Divisors.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers69
Suggested Problems

Extract leading nonzero digit
2106 Solvers

Increment a number, given its digits
641 Solvers

Is my wife right? Now with even more wrong husband
1318 Solvers

Create a vector whose elements depend on the previous element
638 Solvers

Divisible by n, Truncatednumber Divisors
72 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!