Title Description
Description
Write a program that decomposes integer n into the product of a mass factor.
Enter a description
Input Description
Enter an integer N
Output description
Output Description
Output decomposition factorization. In the form of several prime numbers multiplied, prime numbers must be multiplied from small to large.
Sample input
Sample Input
756
Sample output
Sample Output
756=2*2*3*3*3*7
Data range and Tips
Data Size & Hint
The range is within the longint. Not high precision.
#include <stdio.h>#include<math.h>intPrimeinta) { inti; for(i=2; I<sqrt (a); i++) if(a%i==0) return 1; return 0;}intMain () {inti,n,flag=0; scanf ("%d",&N); printf ("%d=", N); for(i=2; i<=n;i++) { if(Prime (i))Continue; while(1) { if(n%i==0) {n/=i; if(n!=1) printf ("%d*", i);Elseprintf ("%d", i); } Else Break; } } return 0;}
codevs1792 decomposition factorization