Problem Statement
NOTE: This problem statement contains superscripts that may not display properly if viewed outside of the applet.
You are given ints n and k. Return the value of the sum 1k + 2k + 3k + ... + nk modulo 1000000007.
Definition
- Class:
- SumOfPowers
- Method:
- value
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int value(int n, int k)
- (be sure your method is public)
Constraints
- n will be between 1 and 109, inclusive.
- k will be between 1 and 50, inclusive.
Examples
5
1
Returns: 15
Here, we have arithmethic progression: 1 + 2 + 3 + 4 + 5 = 15.4
2
Returns: 30
Just a little bit more complicated example here: 12 + 22 + 32 + 42 = 1 + 4 + 9 + 16 = 30.13
5
Returns: 1002001
This one would be harder to check by hand.123456789
1
Returns: 383478132