Interest fund (interest m)
int i,k; for(I = m+ 1; ; i++){
for(k = 2; K< me; k++)
If (i%k==0)
Break;
if(k & gt; =i)
Return (1);
void main()
int n; ?
Printf ("\ nPlease enter n:"); ?
scanf("%d ",& ampn);
printf("%d\n ",fun(n));
}
Extended data:
Thinking about judging prime numbers with c language program;
Idea 1): Therefore, to judge whether an integer m is a prime number, you only need to divide m by every integer between 2 and m-1.If two integers are not divisible, then m is a prime number.
Idea 2): In addition, the judgment method can be simplified. M need not be divided by every integer between 2 ~ m- 1, just by 2 ~? Just divide each integer by √ m.
If m cannot be 2 ~? √m? If any integer is divisible, m must be a prime number. For example, to judge whether 17 is a prime number, you only need to divide 17 by every integer between 2 and 4, and you can judge that 17 is a prime number because it is not divisible.
Reason: Because if m is divisible by any integer between 2 and m-1,then one of its two factors must be less than or equal to? The other is greater than or equal to √ m. ..
For example, 16 is divisible by 2, 4 and 8, 16=2*8, 2 is less than 4, 8 is greater than 4, 16=4*4, 4=√ 16, so it is only necessary to judge whether there is a factor between 2 and 4.