Advertisement
nguyenhappy92

Hãy tìm bội chung nhỏ nhỏ nhất a và b

Oct 6th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. // Cho 2 so nguyen duong a va b, hay tim boi so chung nho nhat
  2. // Khai bao thu vien
  3. #include<stdio.h>
  4. #include<conio.h>
  5. int UCLN(int a,int b);
  6. void main()
  7. {
  8. int a,b;
  9. scanf("%d%d",&a,&b);
  10. printf("%d", (a*b)/(UCLN(a,b)));
  11.  
  12. }
  13.  
  14. int UCLN(int a,int b)
  15. {
  16. while(a!=b)
  17. {
  18. if(a>b)
  19. {
  20. a=a-b;
  21. }
  22. else
  23. {
  24. b=b-a;
  25. }
  26. }
  27. return a;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement