Topic content:
Each non-prime (composite) can be written as a number of primes (also known as prime numbers) in the form of multiplication, and these primes are called the composite's mass factor. For example, 6 can be decomposed into 2x3, and 24 can be decomposed into 2x2x2x3.
Now, your program reads an integer in a [2,100000] range, then outputs its mass factorization, and when it reads a prime number, it outputs itself.
Input format:
An integer that is within [2,100000].
Output format:
Shaped like:
N=axbxcxd
Or
N=n
There are no spaces between all the symbols, and x is the lowercase letter x.
Input Sample:
18
Sample output:
18=2x3x3
time limit: 500ms memory limit: 32000kb
#include <stdio.h>//to decompose a positive integer factorizationintMain () {intI,n; scanf ("%d",&N); printf ("%d=", N); for(i=2; i<=n;i++) { while(n!=i)//if i=n, then factorization is n itself. { if(n%i==0)//If I is a mass factor, the value of I is printed out and the new value is assigned to n by the quotient{printf ("%DX", i); N=n/i; } Else Break;//if not divisible by I, the next i}} printf ("%d\n", n);//here is the last quality factor of the print, which is equal to I return 0;}
Decomposition factorization Onge teacher C Language Programming Cap 5th Chapter programming problem