Cody

Problem 83. Prime factor digits

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

54.27% Correct | 45.73% Incorrect
Last solution submitted on Oct 21, 2017

Problem Comments

Solution Comments

Tags

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!