To find the least common multiple of two numbers in Swift, we can use the following algorithm:
max.lcm and assign it the value of max.lcm.lcm by the value of max.lcm.Here's the Swift code that implements this algorithm:
main.swift193 chars11 linesTo use this function, simply call it and pass in the two numbers whose least common multiple you want to find:
main.swift91 chars7 linesIn this example, the least common multiple of 12 and 18 is 36.
gistlibby LogSnag