MUstar

IoT C언어 0425 - 도전실전3

Apr 25th, 2017
33
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int prime_check(int n);
  3.  
  4. int main(void)
  5. {
  6.     int sc;
  7.     printf("#양수 입력 : ");
  8.     scanf("%d", &sc);
  9.     prime_check(sc);
  10.     return 0;
  11. }
  12.  
  13. int prime_check(int n)
  14. {
  15.     int i,j,k;
  16.     int line=0;
  17.     for(i=2;i<= n ;i++){
  18.         k = 1;
  19.         for(j=2; j< i;j++)
  20.         {
  21.             if((i%j) == 0){k =0;break;}
  22.         }
  23.         if(k == 1)
  24.         {printf("%5d", i); line++; if((line%5)==0) printf("\n");}
  25.         }
  26. }
RAW Paste Data