Problem Statement
Given an int low, an int high, and an int pow, return the sum of i^j, for all i between low and high, inclusive, and all j between 1 and pow, inclusive.
Definition
- Class:
- PowSum
- Method:
- getSum
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int getSum(int low, int high, int pow)
- (be sure your method is public)
Constraints
- low will be between -100 and 100, inclusive.
- high will be between low and 100, inclusive.
- pow will be between 1 and 10, inclusive.
- The return value will fit in a signed 32 bit datatype.
Examples
1
3
2
Returns: 20
1^1 + 2^1 + 3^1 + 1^2 + 2^2 + 3^2 = 1 + 2 + 3 + 1 + 4 + 9 = 20-12
12
9
Returns: 1637738440
Note that intermediate values may exceed the 32 bit restriction.-100
100
2
Returns: 676700