Seasonal Tree Growth

The Utopian Tree grows on a schedule: in spring it doubles, and in summer it grows by one meter. Its starting height is 1. The function utopian_tree receives the number of growth cycles n: odd cycles double the height, and even cycles add 1. Return the tree’s height after all cycles.

Примеры

Ввод
0
Вывод
1
Ввод
1
Вывод
2
Ввод
4
Вывод
7

Нужно реализовать

def utopian_tree(n: int) -> int:

Теги

math
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
0
Expected1
2
Input
1
Expected2
3
Input
4
Expected7
4
Input
5
Expected14
5
Input
2
Expected3
6
Input
3
Expected6
Focus radio
Paused · SomaFM · Fluid