[Gambas-user] Least Common Multiple
Peter Moers
peter.moers at ...626...
Tue Apr 11 00:08:52 CEST 2006
hi,
I'm trying to calculate the least common multiple of 3 integers I
tried the following code but had to find out it doesn't work when
xs,ys or zs equals 0.
DIM vmax AS Integer = Max(xs, ys, zs)
DIM loops AS Integer = vmax
WHILE loops MOD xs <> 0 AND loops MOD ys <> 0 AND loops MOD zs <> 0
loops = loops + vmax
WEND
Now, I can split it up in 3 loops after checking the values for not
being 0 but I think it must be able to do this with less code.
Suggestions?
Maybe LCM could implemented into the Gambas language, would be usefull.
regards,
--
Peter Moers
peter.moers at ...1417...
Divides Webdesign - http://www.divides.be
Startpagina - http://www.321start.be
More information about the User
mailing list