Advertisement
Dechatorn

Ex7

Oct 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num,i,check=0;
  5. scanf("%d",&num);
  6. if(num<=1) check = 1;
  7. else if(num==2) check = 0;
  8. else
  9. {
  10. for(i=2;i<=num/2;i++)
  11. {
  12. if(num%i==0) check=1;
  13. }
  14. }
  15. if(check == 1)
  16. {
  17. printf("Not Prime");
  18. }
  19. else
  20. {
  21. printf("Prime");
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement