Posted 01 May 2015 - 11:50 AM
I am writing a code to test if the area of a circle is (circumfrence/2)*radius. My code is:
http://gyazo.com/4d744346bdc1f17146f8eb804cdbf1bc
Most of them work, but some say they don't work, even though clearly (circ/2)*pi is the same as area.
What is wrong with this code?
pi = 3.1415926535
for i = 1, 200 do
area = (i^2)*pi
circ = (i*2)*pi
if area == (circ/2)*i then
print("Worked")
else
print(area..": "..(circ/2)*i)
end
end
But this produces a weird result, as shown here:http://gyazo.com/4d744346bdc1f17146f8eb804cdbf1bc
Most of them work, but some say they don't work, even though clearly (circ/2)*pi is the same as area.
What is wrong with this code?