fork 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. scanf("%d",&b);
  12. printf("2つ目の正の整数を入力してください:%d\n",b);
  13.  
  14. if(b<=0)
  15. printf("正ではありません。\n");
  16. else
  17. do
  18. {
  19. d=a*c;
  20. c=c+1;
  21.  
  22. }
  23. while(d%b!=0);
  24. printf("\n%dと%dの最小公倍数は%dです。\n",a,b,d);
  25. // your code goes here
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5308KB
stdin
-2
39
stdout
1つ目の正の整数を入力してください:-2
正ではありません。
2つ目の正の整数を入力してください:32767

-2と32767の最小公倍数は-65534です。