Advertisement
makispaiktis

PRIME NUMBERS

Jan 5th, 2018 (edited)
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5.  int n,i, flag=0;
  6.  scanf("%d", &n);
  7.  
  8. /*Checking if n is NOT prime */
  9.  
  10. for(i=2; i<n; i++){
  11.  if(n%i==0){
  12.   flag=1;
  13.  }
  14. }
  15.  
  16. if(flag==0){
  17.     printf("%d is prime.\n", n);
  18. }
  19. else{
  20.     printf("%d is not prime.\n", n);
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement