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.
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 do not understand how this code passes the test.
how can i see this solutions？
tabulate code is not working. I got the correct results but I am getting error --"Undefined function 'tabulate' for input arguments of type 'double"
Tabulate could probably be made to work here, but I recall that Cody does not allow toolbox functions, and tabulate lives in the stats toolbox. I'd guess the logic is that not everyone has all toolboxes, so a solution that uses some tool that others cannot use would not be fair to those others.
Definitely used a bit of a work around in this one. Sorry for that!
great problem...
can't believe 'deblank' can be used in this way
Find relatively common elements in matrix rows
651 Solvers
Number of 1s in the Binary Representation of a Number
320 Solvers
154 Solvers
Vectorize the digits of an Integer
236 Solvers
The sum of the numbers in the vector
344 Solvers