Home > Back-end >  Write a program
Write a program

Time:10-20

Given a positive integer n, the prime factor decomposition result, the so-called prime factor is to look for the number of all is few and few primes
3.
#include
#include
IntIsPrime (intn);
VoidFactorizePrime (intn);
Intmain ()
{
Intn;
The scanf (" % d ", & amp; n);
If (IsPrime (n)==0)
{
Printf (" % d can be decomposed into: ", n);
FactorizePrime (n);
}
The else
Printf (" % d is a prime number, does not decompose \ n ", n);
return0;
}
IntIsPrime (intn)
{
Inti;
For (I=2; i<=(int) SQRT (n); I++)
If I (n %==0)
return0;
Return1;
}
VoidFactorizePrime (intn)
{
Inti;
While (1)
{the for (I=2; i<=n; I++)
If I (n %==0)
{
printf("%d",i);
N=n/I;
break;
}
If (n==1)
break;
}
}

CodePudding user response:

How do you understand look not to understand this program

CodePudding user response:

A function is a function, such as the following function is the judgment of prime Numbers,
IntIsPrime (intn)

This is the judgment factor

VoidFactorizePrime (intn)

CodePudding user response:

If the two break is not in the same layer in the loop?

CodePudding user response:

reference 2 building self-confidence boy reply:
a function is a function, such as the following function is the judgment of prime Numbers,
IntIsPrime (intn)

This is the judgment factor

VoidFactorizePrime (intn)

How settlement post classmates know

CodePudding user response:

reference 4 floor qq_45464245 response:
Quote: refer to the second floor confident boy reply:
a function is a function, such as the following function is the judgment of prime Numbers,
IntIsPrime (intn)

This is the judgment factor

VoidFactorizePrime (intn)

Students how to settle post know

His study, if in the BBS discussion questions for a long time, their research proposals,
  • Related