By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,599 Members | 1,304 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,599 IT Pros & Developers. It's quick & easy.

please help

P: 4
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.
Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
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.
What have got so far?
Nov 14 '06 #2

smartway
P: 24
unless and untill you start something no one is going to help you. You try first and then ask if you have any queries.
Nov 14 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.