fork download
  1. #include <stdio.h>
  2.  
  3. int prime(int n)
  4. {
  5. int i;
  6. for(i=2; i<=n; i++)
  7. {
  8. if(n%i!=0)
  9. return 1;
  10. else
  11. return 0;
  12. }
  13. }
  14.  
  15. int main(void) {
  16. int i;
  17. int n;
  18. scanf("%d",&n);
  19.  
  20. if ((prime(n))==1)
  21. printf("素数です");
  22. else
  23. printf("素数ではありません");
  24.  
  25. // your code goes here
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5328KB
stdin
7
stdout
素数です