CodePudding user response:
This class begin problem, had better write their own, have questions to ask, effect is better,Show a, only supplies the reference:
# include & lt; Stdio. H>
Void func (int n)
{
Int I, j, flag;
For (I=2; I & lt;=n; I++)
{
Flag=1;
For (j=2; J & lt;=I/2; J++)
{
If (n % j==0)
{
Flag=0;
break;
}
}
If (flag==1 & amp; & I n %==0)
{
Printf (" % d \ t ", I);
Func (n/I);
break;
}
}
}
Int main (void)
{
int n;
The scanf (" % d ", & amp; n);
Func (n);
printf("\n");
return 0;
}
CodePudding user response:
For exampleint isPrimeNum (int num) {//it is prime, return 1, not 0
int i;
If (num<2) return 0;
Else if (num==2) return 1;
Else if (num % 2==0) return 0;
For (I=3; iIf (num % I==0) return 0;
}
return 1;
}
Int main ()
{
Int n, I;
The scanf (" % d ", & amp; n);
If (n<2) return 1;
If (isPrimeNum (n)) {//
Printf (" % d itself is prime, no qualitative factor, ", n);
return 0;
}
while (! IsPrimeNum (n)) {//if not prime Numbers has been circulating
For (I=2;; I++) {
If I==0) (n % {
Printf (" % d ", I);
N/a=I;
break;
}
}
}
printf("%d", n);
return 0;
}