0
target="/home/walia6/Math/fib"
os.execute("echo 1 > "..target)
os.execute("echo 1 >> "..target)
while true do
local handle = io.popen("wc -l < "..target)
ct = handle:read("*a")
handle:close()
os.execute("echo "..ct)
tmp=("sed -n "..(ct-1).."p "..target)
--os.execute("echo '"..tmp.."'")
local handle = io.popen(tmp)
pn = handle:read("*a")
handle:close()
tmp=("sed -n "..(ct-0).."p "..target)
--os.execute("echo '"..tmp.."'")
local handle = io.popen(tmp)
cn = handle:read("*a")
handle:close()
os.execute("echo "..(string.format("%.0f",cn+pn)).." >>"..target)
end
위의 코드는 Linux의 Lua를 실험하면서 만든 코드이다. 내가 루아를 테스트하는 것보다 리눅스를 더 많이 테스트했다.임의의 지점에서 정확성에 문제가있다.
피보나치 발전기가 78 번째 숫자가 생성 된 후에 부정확하게 나타났습니다. 이것은 상당히 임의적 인 숫자 인 것 같아서 왜 어떤 종류의 오버 플로우와 같은 오류가 나는지 이유를 생각할 수 없습니다.
누구나 알 수 있습니까?