fork download
  1. E=1e10
  2. for y=1,1e4 do
  3. local x=math.pi*y^2
  4. local s=tostring(math.floor(x))
  5. a,z,b=s:match("^([1-9]+)(000+)(.*)$")
  6. if z and #b<4 then
  7. if b==nil then b="" end
  8. x=tonumber(a..z..string.rep("0",#b))
  9. e=math.abs(x/y^2-math.pi)
  10. if e<E then
  11. print(x,y,x/y^2,string.format("%.10f",math.abs(x/y^2-math.pi)))
  12. E=e
  13. end
  14. end
  15. a,z,b=s:match("^([1-9]+)(999+)(.*)$")
  16. if z and #b<4 then
  17. x=tonumber(a..z..string.rep("9",#b))+1
  18. e=math.abs(x/y^2-math.pi)
  19. if e<E then
  20. print(x,y,x/y^2,string.format("%.10f",math.abs(x/y^2-math.pi)))
  21. E=e
  22. end
  23. end
  24. end
  25. -- your code goes here
Success #stdin #stdout 0.03s 2832KB
stdin
Standard input is empty
stdout
300000	309	3.1419863637792	0.0003937102
600000	437	3.141871193754	0.0002785402
830000	514	3.1416069887508	0.0000143352
2613000	912	3.1415916435826	0.0000010100
51352000	4043	3.141592706503	0.0000000529
91236000	5389	3.1415926293435	0.0000000242
149138000	6890	3.14159264073	0.0000000129
233380000	8619	3.1415926636367	0.0000000100
246113000	8851	3.1415926543257	0.0000000007