I want to implement a program in C++ with which I can see if a number $n$ has a prime factorization of only consecutive primes.
For example $30=2\cdot 3 \cdot 5$ is such a number, while $21=3 \cdot 7$ isn't because $5$ is missing. Repeated prime factors are allowed so $60=2^2 \cdot 3 \cdot 5$ would have the desired property. Before getting my hands on the keyboard I was figuring out how a possible algorithm might look.
Here is what i have so far:
(1) Find the number of prime factors of $n$, call this number $a_1$
(2) Find the maximum of all prime factors of $n$, call it $M$
(3) Find the minimum of all prime factors of $n$, call it $m$
(4) Find the number of primes $< m$ call it $a_2$
(5) Find the number of primes $\leq M$ call it $a_3$
(6) If $a_1=a_3-a_2$ then $n$ has the property that we are looking for.
I have really limited knowledge in programming so the above algorithm would be one (maybe the only) way I am able to implement a program based on my knowledge.
my question : Can I achieve my goal by implementing the above algorithm or is there a serious mistake I overlooked? Thanks in advance !!