I would be thankful for any help!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cNoob
    New Member
    • Nov 2006
    • 4

    I would be thankful for any help!!

    I need to write a program to find the sum, sum of squares, sum of the cubes, and sum of a certain series shown below for the first n integers, begining with 1 and ending with n = 100.

    Summing the first 100 natural numbers:

    n(n+1)
    1 + 2 + 3 + ..... + n = ----------
    2

    Sum of squares of the first 100 natural numbers:

    n(n+1)(2n+1)
    1² + 2² + 3² + ……. n² = -------------------
    6

    Sum of cubes of the first 100 natural numbers:

    n² (n + 1)²
    1³ + 2³ + 3³ + ……. + n³ = --------------
    4

    Another series:

    1 1 1 1 n
    ------- + ------- + ---------- + .......... ---------- = ------
    (1 * 2) (2 * 3) (3 * 4) n*(n+1) n +1

    Since all of these series involve summing the same number of terms, do all of the summing inside ONE(1) loop. Compute the formats outside the loop. Use n as a variable in the formulas; do not replace it with 100, because the formulas work for any n and the program should be flexible enough to easily change the number of terms.
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    implement the program one section at a time, i.e. first Summing the first 100 natural numbers:

    1 + 2 + 3 + ..... + n = n(n+1) / 2

    an algorithm is
    Code:
    sum=0
    for i=1 to 100 
        sum = sum + i
    print sum
    when that is working add the code for the next section, etc

    do you also have to prove the sum = n(n+1) / 2

    Comment

    • cNoob
      New Member
      • Nov 2006
      • 4

      #3
      Originally posted by horace1
      implement the program one section at a time, i.e. first Summing the first 100 natural numbers:

      1 + 2 + 3 + ..... + n = n(n+1) / 2

      an algorithm is
      Code:
      sum=0
      for i=1 to 100 
          sum = sum + i
      print sum
      when that is working add the code for the next section, etc

      do you also have to prove the sum = n(n+1) / 2
      No I dont hve to......... But im So lost please help :(

      Comment

      Working...