YouTip LogoYouTip

Python Exercise Example14

# Python2.x Python Exercise Instance 14 [![Image 3: Python 100 Examples](#) Python 100 Examples](#) **Question:** Decompose a positive integer into its prime factors. For example: input 90, print out 90=2*3*3*5. **Program Analysis:** To decompose n into prime factors, first find the smallest prime number k, and then complete the process according to the following steps: (1) If this prime number is exactly equal to n, it means the process of decomposing prime factors has ended, just print it out. (2) If nk, but n is divisible by k, then print out the value of k, and use the quotient of n divided by k as the new positive integer n, repeat the first step. (3) If n is not divisible by k, then use k+1 as the value of k, repeat
← Python Exercise Example15Python Exercise Example13 β†’