Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- I initially used Microsoft Exel to use this, but because of it's limitations I turned it into a nicer and better script. If you do not know what magic numbers are, don't bother with this script. If you do, you will find this very useful.
- function round(number)
- kek = nil
- local strnum = tostring(number)
- for i=1,#strnum do
- if string.sub(strnum,i,i) == "." then
- kek = tonumber(string.sub(strnum,i+1,i+1))
- kek2 = tonumber(string.sub(strnum,1,i-1))
- end
- end
- if kek ~= nil then
- if kek >= 5 then
- kek2 = kek2 + 1
- else
- kek2 = kek2
- end
- end
- return kek2
- end
- function removedec(number)
- kek = number
- local strnum = tostring(number)
- for i=1,#strnum do
- if string.sub(strnum,i,i) == "." and string.sub(strnum,i+1,i+1) == "0" and string.sub(strnum,i+2,i+2) == "" then
- kek = tonumber(string.sub(strnum,1,i-1))
- end
- end
- return kek
- end
- function notdec(number)
- kek = false
- local strnum = tostring(number)
- for i=1,#strnum do
- if string.sub(strnum,i,i) == "." and string.sub(strnum,i+1,i+1) == "0" and string.sub(strnum,i+2,i+2) == "" then
- kek = true
- end
- end
- return kek
- end
- function findmagicnumbers(a,b,c)
- neg = false
- local sum = a*c
- if sum < 0 then
- neg = true
- sum = sum * -1
- end
- local aon = round(math.sqrt(sum))
- for i=1,aon do
- local ssum = sum/i
- if neg == true then
- i = i*-1
- end
- if b < 0 then
- ssum = ssum*-1
- --if neg ~= true then
- i = i*-1
- -- end
- end
- if --[[neg]]false == false then
- if notdec(ssum) == true then
- if ssum + i == b then
- print("ANS//"..i.." | "..ssum)
- sssum = {i,ssum}
- else
- print(" "..i.." | "..ssum)
- end
- elseif notdec(ssum) == false then
- print("N "..i.." | "..ssum)
- end
- end
- end
- if sssum ~= nil then
- print("------------------------------------\nANSWERS:\n"..sssum[1]..", "..sssum[2])
- end
- end
- findmagicnumbers(1,14,48)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement