Express the algorithm to compute the sum of cubes of all numbers from 1 to N in a flowchart(i.e. 13+23+33+……+N3)
Answers
Answered by
2
13+23+33.......+N3
Input n=1
Answered by
0
Example:-
- Input n=1
- Output=82
- 13+23+33+13=82
Programme:-
- Simple Java program to find sum of series
- // with cubes of first n natural numbers
- import java.util.*;
- import java.lang.*;
- class GFG {
- /* Returns the sum of series */
- public static int sumOfSeries(int n)
{
- int sum = 0;
- for (int x = 1; x <= n; x++)
- sum += x * x * x;
- return sum;
}
- // Driver Function
- public static void main(String[] args)
{
- int n = 1;
- System.out.println(sumOfSeries(n));
}
}
Compile kro...............
Similar questions
Chemistry,
1 month ago
Social Sciences,
1 month ago
Math,
1 month ago
Social Sciences,
3 months ago
Social Sciences,
3 months ago
English,
9 months ago
English,
9 months ago
Math,
9 months ago