This is a Lua program I wrote to find the least common multiple of two numbers. When I run it, it asks for two numbers as intended, but when it tries to run them through the function, it runs out of memory.
function lcm(a,b)
aList={}
bList={}
c=0
if a<b then
repeat
c=c+1
aList[c]=a*c
bList[c]=b*c
aL=table.getn(aList)
until aL==b
else
if a>b then
repeat
c=c+1
aList[c]=a*c
bList[c]=b*c
bL=table.getn(bList)
until bL==a
end
end
e=1
repeat
d=1
repeat
if aList[e]==bList[d] then
f=aList[e]
return f
end
d=d+1
until d==table.getn(aList)
e=e+1
until e==table.getn(bList)
end
n1=io.read()
n2=io.read()
ans=lcm(n1,n2)
print(ans)