Utopian Tree

Utopian Tree
The Utopian Tree goes through 2 cycles of growth every year. Each spring, it doubles in height. Each summer, its height increases by 1 meter.
Laura plants a Utopian Tree sapling with a height of 1 meter at the onset of spring. How tall will her tree be after  growth cycles?

import sys
T = int(sys.stdin.readline())
for _ in range(T):
    N = int(sys.stdin.readline())
    height = 1
    for i in range(N):
        if i % 2 == 0:
            height *= 2
            height += 1


Popular posts from this blog

Super Reduced String Problem Solution