Advertisement
aiNayan

7Ivi)

Dec 7th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. int gcd(int a, int b)
  3. {
  4. if (a == 0)
  5. return b;
  6. return gcd(b % a, a);
  7. }
  8. int lcm(int a, int b)
  9. {
  10. return (a / gcd(a, b)) * b;
  11. }
  12.  
  13. int main()
  14. {
  15. int a, b;
  16. printf("Enter the two number: ");
  17. scanf("%d%d", &a, &b);
  18. printf("LCM = %d ", lcm(a, b));
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement