Some divisors only require a few numbers at the end of the number in question to determine divisibility, no matter how long. Examples include 25, 32, 50, 64, 75, 100, 125, 128, 256, and 512. Notice that this list includes some prime-power divisors (e.g, 25 = 5^2, 32 = 2^5, 125 = 5^3, etc.). Write a function to determine if a given number, provided as a string (n_str), is divisible by the provided divisor. See the test suite for examples and rules for these simple divisors below:
- 25: The last two digits must be divisible by 25.
- 32: The last five digits must be divisible by 32.
- 50: The last two digits must be 00 or 50.
- 64: The last six digits must be divisible by 64.
- 75: The number must be divisible by 3 (can be done by a simple sum) and end in 00, 25, 50, or 75 (last two digits divisible by 25).
- 100: The last two digits must be 00.
- 125: The last three digits must be divisible by 125.
- 128: The last seven digits must be divisible by 128.
- 256: The last eight digits must be divisible by 256.
- 512: The last nine digits must be divisible by 512.
The only restriction that remains is Java.
Previous problem: Divisible by n, prime divisors from 20 to 200. Next problem Divisible by n, Composite Divisors.