problem-5

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

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
a=eval(input())
n=eval(input())
if a==1:
	print(a*n)
else:
	x=a*(pow(a,n)-1)/(a-1)
	print(x)


s=0
p=1
a=int(input(''))
b=int(input(''))
i=0
while i<b:
	p=p*a
	s=s+p
	i=i+1
print(s)


a=eval(input())
b=eval(input())
S=0
for i in range(0,b):
	S+=pow(a,i)*a
print(S)


a=int(input())
n=int(input())
s=0
i=1
while i<=n :
	s=s+a**i
	i=i+1
print(s)


#!/usr/bin/env python
#-*- coding: utf-8 -*-

a = int (input ())
n = int (input ())
if a != 1:
	print(a * ((a ** n) - 1) / (a - 1))
else:
	print(n)


a=eval(input())
b=eval(input())
if a==1:
	print(b)
else:
	print(a*(2**b-1))
	


x=eval(input())
y=eval(input())
sum=0
for i in range(1,y+1):
	sum=sum+pow(x,i)
print(sum)


a=eval(input())
b=eval(input())
if a>1:
	x=a-1
	print(int(a*(a**b-1)/x))
else:
	print(b*a)