Problem 42508. Divisible by n, prime divisors from 20 to 200
Pursuant to the previous problem (linked below), this problem requires a function that checks for divisibility of large numbers for any prime number from 20 to 200. Similar to the previous problem, these can all be checked using the same routine: add or subtract x times the last digit to or from the remaining number after removing that last digit. For example, for 127, the last-digit factor is -38:
- 2048379: 204837 + -38*9 = 204495: 20449 + -38*5 = 20259: 2025 + -38*9 = 1683: 168 + -38*3 = 54 -> 2048379 is not divisible by 127 since 54 is not divisible by 127.
- 4853940: 485394 + -38*0 = 485394: 48539 + -38*4 = 48387: 4838 + -38*7 = 4572: 457 + -38*2 = 381: 38 + -38*1 = 0 -> 4853940 is divisible by 127.
Your function will be provided with the prime number, n, and the number to check for divisibility as a string, n_str. Write a function that returns true or false for each prime number and candidate number pair. See the test suite for more examples. The template function will include arrays of all possible prime number in the given range in addition to a paired array with the associated factors.
Restrictions on Java, mod, ceil, round, and floor are still in effect.
Previous problem: Divisible by n, prime divisors - 11, 13, 17, & 19. Next problem: Divisible by n, Truncated-number Divisors.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers65
Suggested Problems
-
2305 Solvers
-
648 Solvers
-
11357 Solvers
-
Given a window, how many subsets of a vector sum positive
854 Solvers
-
1346 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!