The mysterious pathogen of ACM Nation multiplies mysteriously each day. Maria was able…
- User
The mysterious pathogen of ACM Nation multiplies mysteriously each day. Maria was able to
decipher the pattern but unable to completely solve the problem. The study of this equation will
help in combating their growth.
The summation is -
S = a + aa + aa*a + ...... a^n times
Where a is the number of pathogen on the first day and S on the nth day. Input : a and n are taken as input from the user. First line will contain a,followed by n.
Output: a single integer depicting the sum
Sample Input: 2 4
Sample Output: 30
SAMPLE INPUT 2 4
SAMPLE OUTPUT 30
Assistant
a = int(input()) n = int(input()) if a == 1: print(1 + 2 * (n - 1)) else: sum_part = (pow(a, n-1) - 1) // (a - 1) total = a + 2 * a * sum_part print(total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.