MUstar

IoT C언어 0419 - 도전실전2

Apr 19th, 2017
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     int i,j,k;
  6.     int n1 ,line=0;
  7.    
  8.     printf("2이상의 정수를 입력하세요 : ");
  9.     scanf("%d", &n1);
  10.    
  11.     for(i=2;i<= n1 ;i++){
  12.         k = 1;
  13.         for(j=2; j< i;j++)
  14.         {
  15.             if((i%j) == 0){k =0;break;}
  16.         }
  17.         if(k == 1)
  18.         {printf("%5d", i); line++; if((line%5)==0) printf("\n");}
  19.     }
  20. }
RAW Paste Data