fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a,i,count=0;
  5. scanf("%d",&a);
  6. for(i=1;i<=a;i++){
  7. if(a%i==0){
  8. count++;
  9. }
  10. }
  11. if(count==2){
  12. printf("入力された数字:%d\n素数です",a);
  13. }
  14. else
  15. printf("入力された数字:%d\素数ではありません",a);
  16. return 0;
  17. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
入力された数字:32766素数ではありません