echo utopianTree(5)."\n";
//Using for loops
function utopianTree($n) {
$val = 1;
for ($i = 0; $i < $n; $i++) {
if ($i%2 == 0) {
//doubled for each odd year
$val *= 2;
} else {
//increased by one for each even year
$val++;
}
}
return $val;
}