Thursday, October 10, 2013

ALGORITHM TO FIND SUM OF THE SERIES 1*5 - 2*7 + 3*9 - 4*11 ... UPTO N TERMS


STEP 1.      I <-- 1, J=5, Sum <-- 0, N <-- 0, Sign=1
STEP 2.      Read N
STEP 3.      While (I <= N)
        Begin
             Sum <-- Sum+  Sign*(I * J)
         J <-- J + 2
      I <-- I + 1
      Sign= Sign * (-1)
             End
STEP 4.      Print Sum

No comments:

Post a Comment