1. Takayuki KONDO
  2. playground

Commits

Takayuki KONDO  committed 901ba2c

py: pi

  • Participants
  • Parent commits 521cfba
  • Branches default

Comments (0)

Files changed (1)

File py/numpy/pi.py

View file
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+def ppii(n=50):
+    a, b, i = 10**n, 10**n, n*8+1
+    while i >= 3:
+        a, i = (a+b+b)*(i/2)/i, i-2
+    return a - b
+
+
+def ee(n=50):
+    a, b, i = -10**(n+5), 10**(n+5), 2
+    while b > 0:
+        a, b, i = a+b, b/i, i+1
+    return a/100000
+
+print "3."+str(ppii(100))
+print "2."+str(ee(4))