Advertisement
LuckyCipher

isPrime.c

Jan 28th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.    
  5.     int n = 100;
  6.     int i;
  7.     int j;
  8.     for(i = 3;i<=100;i++){
  9.         int isPrime = 1;
  10.         for(j = 2;j<i;j++){
  11.             if( i % j == 0 ){
  12.                 isPrime = 0;
  13.             }
  14.         }
  15.         if(isPrime){
  16.             printf("%d is prime\n",i);
  17.         }
  18.     }
  19.    
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement