pi.rb 265 B

1234567891011121314151617
  1. class Integer
  2. def divide
  3. return 4.0 / (self * 2 - 1);
  4. end
  5. end
  6. answer = 4.0 / 1
  7. c = 2
  8. while c < 10000000 do
  9. if (c % 2 == 0) then
  10. puts (answer = answer - c.divide)
  11. else
  12. puts (answer = answer + c.divide)
  13. end
  14. c += 1
  15. end