CarlosLabs
Hackerrank Challenges - Utopian tree
(CM: use modulo math for this)
#!/bin/python3 import math import os import random import re import sys # Complete the utopianTree function below. def utopianTree(n): growth = 1 for i in range(n): if ((i % 2)==0): growth=(growth *2) else: growth+=1 return(growth) if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') t = int(input()) for t_itr in range(t): n = int(input()) result = utopianTree(n) fptr.write(str(result) + '\n') fptr.close()