Guest User

Untitled

a guest
Feb 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. char * isPrime(int i){
  6. int c, flag;
  7. for(c = 2; c <= i/2; i++)
  8. {
  9. if((i % c) == 0){
  10. flag = 1;
  11. break;
  12. }
  13. }
  14. if(flag == 0)
  15. return "yes";
  16. else
  17. return "no";
  18.  
  19. }
  20. int main(int argc, char **argv){
  21.  
  22. if(argc < 2){
  23. printf("error\n");
  24. exit(0);
  25. }
  26.  
  27. int input = atoi(argv[1]);
  28. printf("%s\n", isPrime(input));
  29. return 1;
  30. }
Add Comment
Please, Sign In to add comment