Sum of a Geometric Series
Sum the geometric series 1 + R + R^2 + ... + R^K recursively.
Input format
A single line with two integers R (1 <= R <= 9) and K (1 <= K <= 15).
Output format
Print the sum of the geometric series 1 + R + R^2 + ... + R^K.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
2 3Expected output
15Example 2
Input
3 2Expected output
13