flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 75: Compute LCM
Idiom # 75: Compute LCM
See
programming-idioms.org
:
Code
a * b / (a.gcd b)
What are effects?
Running example
ex75 is lcm (a,b int) int is a * b / (a.gcd b) a := int 2147483647 # is the eighth Mersenne prime, equal to 231^-1 b := int 2305843009213693951 # another Mersenne prime x := lcm a b say x
What are effects?
next: Idiom # 76: Binary digits from an integer