Advertisement
BobMe

Number Splitter

Aug 28th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function split(x)
  2. local tab = {}
  3. for i=1,#x do
  4. local num = string.sub(x,i,i)
  5. for k=1,#x-i do
  6. num = num.."0"
  7. end
  8. if tonumber(num) ~= 0 then
  9. -- if num ~= "50" and num ~= "5" and num ~= "500" then
  10. local numberofzeros = #num-1
  11. for i=1,tonumber(string.sub(num,1,1)) do
  12. local newnum = 1
  13. for i=1,numberofzeros do
  14. newnum = newnum.."0"
  15. end
  16. table.insert(tab,newnum)
  17. end
  18. -- end
  19. end
  20. end
  21. return tab
  22. end
  23.  
  24. local a = ""
  25. local k = split("396")
  26. for i=1,#k do
  27. if i ~= #k then
  28. a = a..k[i].."+"
  29. else
  30. a = a..k[i]
  31. end
  32. end
  33.  
  34. print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement