fork download
  1. //2第4回提出
  2. #include <stdio.h>
  3. int soso(int n){
  4. int k;
  5. int l=n;
  6. for(k=2; k<=n; k++){
  7. if(l%k==0){
  8. printf("%d",k);
  9. if(l==k){
  10. return 0;
  11. }
  12. else{
  13. printf("×");
  14. l=l/k;
  15. k=2;
  16. }
  17.  
  18. }
  19. }
  20. }
  21.  
  22. int main(void) {
  23. int x;
  24. do{
  25. printf("3以上の整数を入力してください:");
  26. scanf("%d",&x);
  27. printf("%d\n",x);
  28. }
  29. while(x<3);
  30.  
  31. printf("%d=",x);
  32.  
  33. soso(x);
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5320KB
stdin
2
1974
stdout
3以上の整数を入力してください:2
3以上の整数を入力してください:1974
1974=2×3×7×47