wap in java to find the sum of the series :s=(1*2)+(2*3)+.......to n
Answers
Answered by
0
(3*3) this is the right answer of this answer
Answered by
0
Here the logic is the number has to be added to the result of multiplication of previous number and current number.
int n = 10;
int sum=0;
int previousnum = 1;
for(int i=1; i<=n; i++) {
previousnum += previousnum * (i+1);
sum += previousnum;
}
System.out.println(sum);
If n = 5, then (1*2)+(2*3)+(3*4)+(4*5) = 39
The main logic is implemented in the below line
previousnum += previousnum * (i+1);
sum += previousnum;
Similar questions
History,
5 months ago
Physics,
5 months ago
Accountancy,
11 months ago
Math,
11 months ago
Business Studies,
1 year ago
Biology,
1 year ago