Advertisement
RA2lover

least common multiple calculator attempt

Dec 8th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. table={197248, 54480, 305745, 1329408, 4096, 524288, 1536, 196608, 2048,8192}
  2.  
  3. function calculatelcm(table)
  4. for n=2,10000000 do -- 100M should be enough. it takes a while to calculate it though:-/
  5. correct=0
  6. for k,v in pairs(table) do
  7. if (n/k)%1 == 0 then correct=correct+1
  8. end
  9. if correct>=#table then print(n) break end
  10. end
  11. end
  12. end
  13.  
  14. calculatelcm(table)
  15. print("done") -- just in case it doesn't output anything
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement