Problem 42453. Divisible by n, prime vs. composite divisors
In general, there are two types of divisibility checks; the first involves composite divisors and the second prime divisors, including powers of prime numbers (technically composite divisors, though they often function similar to prime numbers for the sake of divisibility). We'll get into the specifics of the two divisibility check types in subsequent problems. For now, we'll segregate numbers into three groups, based on type (n_type) while also returning the number's highest-power factorization (hpf). Write a function to return these two variables for a given number; see the following examples for reference:
n = 11 | n_type = 1 (prime) | hpf = [11] n = 31 | n_type = 1 (prime) | hpf = [31] n = 9 | n_type = 2 (prime power) | hpf = [9] (3^2) n = 32 | n_type = 2 (prime power) | hpf = [32] (2^5) n = 49 | n_type = 2 (prime power) | hpf = [49] (7^2) n = 21 | n_type = 3 (composite) | hpf = [3,7] n = 39 | n_type = 3 (composite) | hpf = [3,13] n = 42 | n_type = 3 (composite) | hpf = [2,3,7] n = 63 | n_type = 3 (composite) | hpf = [9,7] ([3^2,7]) n = 90 | n_type = 3 (composite) | hpf = [2,9,5] ([2,3^2,5])
Previous problem: divisible by 16. Next problem: Divisible by n, prime divisors (including powers).
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers106
Suggested Problems
-
How to find the position of an element in a vector without using the find function
2694 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
595 Solvers
-
Fix the last element of a cell array
1183 Solvers
-
4535 Solvers
-
3541 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!