Another way to see if a number is prime is to count the number of factors. For example,

the number 4 has 2 factors, [ 2 4 ]
the number 16 has 4 factors, [ 2 4 8 16 ]
the number 7 has 1 factor, [ 7 ]

Thus, if a number has only one factor, it is prime. We ignore the factor 1 as it is trivial.

Your function should create a vector containing all the factors of any number x.

Solution Stats

42 Solutions

31 Solvers

Last Solution submitted on Jul 13, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...

Problem Recent Solvers31

Suggested Problems

More from this Author52

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!