Python function returning first value twice
<p>I've written this function to calculate sin(x) using Taylor series to any specified degree of accuracy, 'N terms', my problem is the results aren't being returned as expected and I can't figure out why, any help would be appreciated.</p>

<p>What is am expecting is: 
1  6.28318530718
2  -35.0585169332
3  46.5467323429
4  -30.1591274102
5  11.8995665347
6  -3.19507604213
7  0.624876542716
8  -0.0932457590621
9  0.0109834031461</p>

<p>What I am getting is:
1 None
2 6.28318530718
3 -35.0585169332
4 46.5467323429
5 -30.1591274102
6 11.8995665347
7 -3.19507604213
8 0.624876542716
9 -0.0932457590621 </p>

<p>Thanks in advance.</p>

<pre><code>def factorial(x):
    if x &lt;= 1:
        return 1
    else:
        return x * factorial(x-1)

def sinNterms(x, N):
    x = float(x)

    while N &gt;1:
        result = x
        for i in range(2, N):
            power = ((2 * i)-1)
            sign = 1
            if i % 2 == 0:
                sign = -1
            else:
                sign = 1
            result = result + (((x ** power)*sign) / factorial(power))
        return result

pi = 3.141592653589793
for i in range(1,10):
    print i, sinNterms(2*pi, i)
</code></pre>