寫一個判斷是否為質數的程式
We have the uncompleted program below:
#include <stdio.h>
int is_prime(int n)
{
/*INSERT YOUR CODE HERE*/
/*在這裡寫你的程式*/
/*END OF YOUR CODE*/
}
int main(void)
{
int n;
scanf("%d", &n);
if (is_prime(n)) // function return 1
printf("Prime");
else // function return 0
printf("Not prime");
return 0;
}
Please complete this program by only insert your code between those tags:
/*INSERT YOUR CODE HERE*/
/*END OF YOUR CODE*/
Remember: A prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself.
You may correct the cases, but your code always be revised!