Advertisement
BobMe

Math solver thing

Apr 26th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. -- Some math solver thing
  2. -- Not sure what kind of math it is but it solves it
  3.  
  4. function removedec(number)
  5. kek = number
  6. local strnum = tostring(number)
  7. for i=1,#strnum do
  8. if string.sub(strnum,i,i) == "." and string.sub(strnum,i+1,i+1) == "0" and string.sub(strnum,i+2,i+2) == "" then
  9. kek = tonumber(string.sub(strnum,1,i-1))
  10. end
  11. end
  12. return kek
  13. end
  14.  
  15. function solve(tab)
  16. local bab = {}
  17. for i=1,#tab do
  18. local num = tab[i]
  19. local neg = false
  20. num = num/2
  21. if num < 0 then
  22. neg = true
  23. num = num * -1
  24. end
  25. if neg == true then
  26. sum = i.." | ".."(x-"..removedec(num)..")² | C : "..removedec(num*num)
  27. else
  28. sum = i.." | ".."(x+"..removedec(num)..")² | C : "..removedec(num*num)
  29. end
  30. table.insert(bab,#bab+1,sum)
  31. end
  32. for i=1,#bab do
  33. print(bab[i])
  34. end
  35. end
  36.  
  37. solve({15})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement