Problem Statement
You will be given a positive integer n. You will return a int[] that contains 3 elements:
n = 3
- Element 0: The sum of all integers from 1 to n inclusive
- Element 1: The sum of the squares of all integers from 1 to n inclusive
- Element 2: The sum of the cubes of all integers from 1 to n inclusive
n = 3
- Element 0 = 1 + 2 + 3 = 6
- Element 1 = 1*1 + 2*2 + 3*3 = 14
- Element 2 = 1*1*1 + 2*2*2 + 3*3*3 = 36
Definition
- Class:
- SimpleSums
- Method:
- compute
- Parameters:
- int
- Returns:
- int[]
- Method signature:
- int[] compute(int n)
- (be sure your method is public)
Notes
- The return value will always be within the bounds of an integer.
Constraints
- n will be between 1 and 100 inclusive
Examples
3
Returns: { 6, 14, 36 }The example from above1
Returns: { 1, 1, 1 }Only a single number100
Returns: { 5050, 338350, 25502500 }As big as it gets10
Returns: { 55, 385, 3025 }