Home > Back-end >  Ask bosses
Ask bosses

Time:09-19

Enter an integer greater than 3 n (n 1000), output (including 3 and n) between 3 to n primes the sum of the squares of the, such as: 9 input and output of 83? This code should how to write? Tried several times with the for statement is correct, consult bosses

CodePudding user response:

The code to see where is it

CodePudding user response:

Write a function to judge whether a prime number
 int judge_prime (int num) 
{
For ()//2 to num 1
{
Can be divided exactly by
If (to) break; return 0;
}
return 1;
}


Int judge=judge_prime (num)
If (judge==)
Sum=sum + num * num;
So, probably in the loop

CodePudding user response:

quoted strings on the second floor of ground response:
write a function to judge whether a prime number
 int judge_prime (int num) 
{
For ()//2 to num 1
{
Can be divided exactly by
If (to) break; return 0;
}
return 1;
}


Int judge=judge_prime (num)
If (judge==)
Sum=sum + num * num;
So, probably in the cycle can

Thank you bosses!
  • Related