Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int num, i;
- printf("Enetr a number. We can check if it is a prime number.\n");
- scanf("%d",&num);
- if(num == 1)
- {
- printf("%d is not a prime number",num);// 1 is not a prime numebr. When num == 1, return 0.
- return 0;
- }
- else
- {
- for(i = 2; i < num; i++)
- {
- if(num % i == 0)
- {
- printf("%d is not a prime number",num);
- return 0;
- }
- }
- printf("%d is a prime number",num);
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment