Hi, I have been trying to turn stuff like 30 into three 10s or 45 into four 10s and one 5.
I have tried with the code below which doing numbers like 30 work, but numbers like 15 only print the 10 out.
function turnNumberToMoney(n)
if n < 10 then
return n
end
local nums = {}
repeat wait()
if n ~= 10 then
if n > 10 then
table.insert(nums,10)
n = n - 10
else
table.insert(nums,n)
break
end
else
if n == 10 then
table.insert(nums,10)
end
if n == 5 then
table.insert(nums,5)
end
break
end
until n < 10
return nums
end
local num = turnNumberToMoney(15)
for i,v in pairs(num) do
print(v)
end

4 comments
This is a pretty standard interview question, so plenty of stuff will come up if you Google it: https://www.geeksforgeeks.org/find-minimum-number-of-coins-that-make-a-change/
in LUA code?
whenever i look it up i get stuff about decimals
math.floor(36/10) + math.floor(36 - (36/10) /5)?