Advertisement
AnicPro

Zadatak 8 - Prosti brojevi od 1 do 100

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