RosettaCodeData/Task/Least-common-multiple/PureBasic/least-common-multiple.purebasic

18 lines
256 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
Procedure GCDiv(a, b); Euclidean algorithm
Protected r
While b
r = b
b = a%b
a = r
Wend
ProcedureReturn a
EndProcedure
Procedure LCM(m,n)
Protected t
If m And n
t=m*n/GCDiv(m,n)
EndIf
ProcedureReturn t*Sign(t)
EndProcedure