Lucky Numbers (Codeforces 630C)
Tags: Math, combinatorics

The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given that a door-plate can hold a number not longer than n digits.

Input: The only line of input contains one integer n (1 ≤ n ≤ 55) — the maximum length of a number that a door-plate can hold.

Output: Output one integer — the maximum number of offices, than can have unique lucky numbers not longer than n digits.


Sample Inputs:
2

Sample Outputs:
6

Solution (Python):
def count_lucky_numbers(n):
    count = 0
    for length in range(1, n + 1):
        count += 2 ** length
    return count
n = int(input())
print(count_lucky_numbers(n))

Solution (Python):
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += 2 ** i
print(ans)

Solution (Python):
count = int(input())
print(sum((2 ** (i + 1) for i in range(count))))