Thread: series equation?!

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    2

    series equation?!

    I am not mainly asking about a code but I would like to have

    some help with how to start logically with solving this series:

    II=4*(1-1/3+1/5-1/7+1/9-1/11+1/13-.....)

    the program will ask the user about the number of terms he

    wants,

    and then depend on these terms calculate and display the

    approxmation of II.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    for ( i = 1 ; i <= 13 ; i += 2 )
    That generates all the denominators for your terms in your series

    int sign = 1;
    sign = sign * -1;
    If you keep doing that in a loop, sign alternates between +1 and -1
    Use this to alternately add and subtract successive terms
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    2
    many thanks for your great help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. differential equation??
    By kypronite in forum Game Programming
    Replies: 11
    Last Post: 09-03-2008, 05:25 PM
  2. Replies: 15
    Last Post: 11-04-2006, 04:06 AM
  3. IDEA: Equation solver
    By Magos in forum Contests Board
    Replies: 2
    Last Post: 01-07-2003, 11:46 AM
  4. factorials, square roots, and infinite series
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 06-05-2002, 01:48 PM
  5. Quadratic Equation Program
    By Ambizzy in forum C Programming
    Replies: 4
    Last Post: 02-19-2002, 09:21 PM