Problem 42454. Divisible by n, prime divisors (including powers)
For this problem, you will be provided an array of numbers (not necessarily in order). Return the array of numbers with only prime divisors (including prime powers) remaining in the array. For example:
n = 1:10; n_p = [2 3 4 5 7 8 9];
Since the prime numbers in the 1:10 range are 2, 3, 5, and 7, while the prime powers in this range are 4 (2^2), 8 (2^3), and 9 (3^2). (Ignore one, as it is a trivial case since all integers are divisible by one.) Therefore, you should return the array including both sets joined together and sorted, as shown in the example above.
Previous problem: Divisible by n, prime vs. composite divisors. Next problem: Divisible by n, prime divisors - 11, 13, 17, & 19.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers89
Suggested Problems
-
15722 Solvers
-
Determine if a Given Number is a Triangle Number
375 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
602 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
11200 Solvers
-
Matrix multiplication across rows
323 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!