LCM — ProgramsLOGO
last changed 29 May 2008
 

LCM

; LCM doesn't quite work right yet.. the intent
; is to provide a stopping point for spingon
; which ensures a complete picture without
; having to make 360 revolutions
; thanks to Joel Arbuckle & Piers so far

to LCM :one :two
let [ :num (:one * :two) ]
let [ :t (int (sqrt (min :one :two))) ]
repeat :t
[
if :t < 1 [output :num]
let [ :test (:num / :t) ]
ifelse ((:test mod :one = 0) and (:test mod :two = 0))
[ set :num :test ]
[ set :t (:t - 1) ]
]
output :num
end
1