detective1711

Check SNT

Oct 26th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. //Kiem tra so nguyen to_By CQH
  2. //Trinh Cong Quang_12520344
  3.  
  4. #include <stdio.h>
  5. #include <math.h>
  6. #include <conio.h>
  7.  
  8. void main()
  9.     {
  10.         int n, i,j=0;
  11.         while(n<=0)
  12.             {
  13.                 printf("Vui long nhap vao so nguyen duong can kiem tra\n\n");
  14.                 scanf("%d", &n);
  15.             }
  16.         if(n==1)
  17.             printf("%d khong phai la so nguyen to\n",n);
  18.         else
  19.             for(i=2;i<=(int)sqrt(n);i++)
  20.             if(n%i==0)
  21.                 {
  22.                     j=1;
  23.                     break;
  24.                 }  
  25.         if(j==1)
  26.             printf("%d khong phai la so nguyen to\n\n",n);
  27.         else
  28.             printf("%d la so nguyen to\n\n",n);
  29.            
  30.         getch();
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment