fork(9) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a,b,d;
  5. int c=2;
  6. scanf("%d",&a);
  7. printf("1つ目の正の整数を入力してください:%d\n",a);
  8. if(a<=0)
  9. printf("正ではありません。\n");
  10. else
  11. {
  12. scanf("%d",&b);
  13. printf("2つ目の正の整数を入力してください:%d\n",b);
  14.  
  15. if(b<=0)
  16. printf("正ではありません。\n");
  17. else
  18. {
  19. do
  20. {
  21. d=a*c;
  22. c=c+1;
  23.  
  24. }
  25. while(d%b!=0);
  26. printf("\n%dと%dの最小公倍数は%dです。\n",a,b,d);
  27. }
  28. }
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5300KB
stdin
47
2
stdout
1つ目の正の整数を入力してください:47
2つ目の正の整数を入力してください:2

47と2の最小公倍数は94です。