The aim of the kata is to try to show how difficult it can be to calculate decimals of an irrational number with a certain precision. We have chosen to get a few decimals of the number "pi" using
the following infinite series (Leibniz 1646–1716): 

PI / 4 = 1 - 1/3 + 1/5 - 1/7 + ... which gives an approximation of PI / 4.

http://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80

To have a measure of the difficulty we will count how many iterations are needed to calculate PI with a given precision. 

There are several ways to determine the precision of the calculus but to keep things easy we will calculate to within epsilon of your language Math::PI constant. In other words we will stop  the iterative process when the absolute value of the difference between our calculation and the Math::PI constant of the given language is less than epsilon.

Your function returns an array or an arrayList or a string or a tuple depending on the language (See sample tests) where your approximation of PI has 10 decimals 

In Haskell you can use the function "trunc10Dble" (see "Your solution"); in Clojure you can use the function "round" (see "Your solution");in OCaml or Rust the function "rnd10" (see "Your solution") in order to avoid discussions about the result.

Example :
```
your function calculates 1000 iterations and 3.140592653839794 but returns:
iter_pi(0.001) --> [1000, 3.1405926538]
```

Unfortunately, this series converges too slowly to be useful, 
as it takes over 300 terms to obtain a 2 decimal place precision. 
To obtain 100 decimal places of PI, it was calculated that
one would need to use at least 10^50 terms of this expansion!

About PI : http://www.geom.uiuc.edu/~huberty/math5337/groupe/expresspi.html

Difficulty: introductory

Starter code:

def iter_pi(epsilon):
	

Solutions:
from math import pi

def iter_pi(epsilon):
    n = 1
    approx = 4
    while abs(approx - pi) > epsilon:
        n += 1
        approx += (-4, 4)[n % 2] / (n * 2 - 1.0)
    return [n, round(approx, 10)]

from math import pi

def iter_pi(epsilon):
    pi_4 = 0
    k = 0
    while abs(pi_4 * 4 - pi) > epsilon:
        pi_4 += (-1) ** k / (k * 2 + 1)
        k += 1
    return [k, round(pi_4 * 4, 10)]

import itertools
from math import pi

def iter_pi(epsilon):
    sign = 1
    value = 4
    n = 1
    for i in itertools.count(1):
        if abs(value - pi) < epsilon:
            return [i, round(value, 10)]
        sign = -sign
        n += 2
        value += sign * (4 / n)

import math
def iter_pi(epsilon):
  pi, iD, c, pos = 4.0, 1.0, 1, False
  while abs(pi - math.pi) > epsilon:
    iD += 2.0
    pi, pos = 4 * (pi / 4 + (1 / iD if pos else -1 / iD)), not pos
    c += 1
  return [c, round(pi, 10)]

from math import pi

def iter_pi(epsilon):
    my_pi = 0
    n = sign = 1
    
    while epsilon < abs(pi - my_pi):
        my_pi += 4.0 / n * sign
        n += 2
        sign *= -1
    
    return [n//2, round(my_pi, 10)]

from math import pi
def iter_pi(epsilon):
    sum, n = 0, 0
    while abs(4*sum - pi)> epsilon:
        sum += ((-1)**n)/(2*n+1)
        n += 1
    return [n, round(4*sum, 10)]

from math import pi

def iter_pi(epsilon):
    res = 0
    i = 0
    while abs(pi-res) > epsilon: 
        res += (-1)**(i%2) * 4 / (1 + (2*i))
        i += 1
    return [i, round(res, 10)]

from math import pi,pow
def iter_pi(epsilon):
    i=0
    leibniz_i=1
    while(abs(4*leibniz_i - pi) >epsilon):
        i+=1
        leibniz_i+=pow((-1),(i))*1/(2*i+1)
    return [i+1,round(leibniz_i*4,10)]


import math
def iter_pi(epsilon):
    pi,k = 0,0
    while abs(pi-math.pi/4) > epsilon/4:
        pi += (-1)**k * 1/(2*k + 1)
        k += 1
    pi *=4

    return [k , round(pi, 10)]

import math

def iter_pi(epsilon):
    my_pi = i = 0
    while abs(my_pi - math.pi) > epsilon:
        my_pi += 4 * math.pow(-1, i) / (2 * i + 1)
        i += 1
    return [i, round(my_pi, 10)]