Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | a | |||
integer, | intent(in) | :: | b |
ELEMENTAL FUNCTION lcm(a, b) INTEGER, INTENT(IN) :: a, b INTEGER :: lcm INTEGER :: tmp tmp = gcd(a, b) IF (tmp == 0) THEN lcm = 0 ELSE ! could still overflow if the true lcm is larger than maxint lcm = ABS((a/tmp)*b) END IF END FUNCTION lcm