Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int check_n(int x)
- {
- int i=2;
- for(;i<=sqrt(x);i++)
- if(x%i==0)
- return 0;
- return x>1?1:0;
- }
- int main()
- {
- int tmp,i=0;
- for(;i<10;i++)
- {
- tmp=rand()%100+1;
- printf("num:%4d , %s\n",tmp,check_n(tmp)==0?"No":"Yes");
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement