Consider the following number system. Calculate the prime factorization for each number n, then represent the prime factors in a vector like so:
13 11 7 5 3 2
---------------
2: 1
3: 1 0
4: 2
5: 1 0 0
6: 1 1
12: 1 2
14: 1 0 0 1
18: 2 1
26: 1 0 0 0 0 1
60: 1 1 2
Each "place" in the number system represents a prime number. Given n, return the vector p.
As shown above, if n = 26, then p = [1 0 0 0 0 1].
The input n is always an integer greater than 1. Suppress any leading zeros. The length of the vector is determined by the largest prime factor.
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers2540
Suggested Problems
-
The Goldbach Conjecture, Part 2
2413 Solvers
-
Omit columns averages from a matrix
620 Solvers
-
Project Euler: Problem 5, Smallest multiple
1652 Solvers
-
Generate N equally spaced intervals between -L and L
944 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
908 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I think the explanation in the problem statement is a bit sparse. The numbers in the table do not represent prime numbers per se: they represent indices on prime numbers, whose ultimate product yields the value n.
See http://mathworld.wolfram.com/PrimeFactorization.html
The in-built function factors() was pretty helpful for this problem :)
I'm sure Test 4 & 6 are incorrect!
@Peter, what makes you think so?
@Dyuman Joshi,
I was wrong! My thinking was wrong!