fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n=100;
  5. int count=0;
  6. int i,j,is_prime;
  7. for(i=n;i>=2;i--){
  8. is_prime=1;
  9. for(j=2;j<i;j++){
  10. if(i%j==0){
  11. is_prime=0;
  12. break;
  13. }
  14. }
  15. if(is_prime==1)count++;
  16. }
  17. printf("%d以下の素数は%d個である\n",n,count);
  18.  
  19.  
  20.  
  21.  
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
100以下の素数は25個である