Help me with this code

chovdary at gmail.com chovdary at gmail.com
Tue Nov 5 20:51:00 EST 2013


Hi friends

help me with the following code. Im able to execute the code but getting wrong output

def sequence_b(N):
    N = 10
    result = 0
    for k in xrange (1,N):
        result  +=  ((-1) ** (k+1))/2*k-1
        print result
print sequence_b(10)

This is the output which im getting
-1
-4
-5
-10
-11
-18
-19
-28
-29


But i want output as
1
-1/3
1/5
-1/7
1/9
-1/11
1/13
-1/15
1/17
-1/19





More information about the Python-list mailing list