Java decomposes a positive integer into prime factors

Program analysis: to decompose the prime factor of N, first find a minimum prime number k, and then complete it according to the following steps: 1. If this prime number is exactly equal to N, it indicates that the process of decomposing the prime factor has ended, and print it out.

2. If n < > k, but n can be divided by K, print out the value of K and divide n by K as a new positive integer. Repeat step 1.

3. If n cannot be divided by K, repeat the first step with K + 1 as the value of K.

Programming:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>