Advertisement
Guest User

Untitled

a guest
Nov 20th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. int check_n(int x)
  6. {
  7.     int i=2;
  8.     for(;i<=sqrt(x);i++)
  9.                        if(x%i==0)
  10.                                  return 0;
  11.     return x>1?1:0;
  12. }
  13.  
  14. int main()
  15. {
  16.     int tmp,i=0;      
  17.     for(;i<10;i++)
  18.                   {
  19.                  tmp=rand()%100+1;
  20.                  printf("num:%4d , %s\n",tmp,check_n(tmp)==0?"No":"Yes");
  21.                  }
  22.     getch();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement