📌  相关文章
📜  javascript代码示例中的乌托邦树hackerrank解决方案

📅  最后修改于: 2022-03-11 15:01:42.186000             🧑  作者: Mango

代码示例1
// Utopian Tree hackerrank solution in javascript
function utopianTree(n) {
    // Write your code here
    let cycle = 1;
    let height = 1;
    for(cycle; cycle<=n; cycle++){
        if(cycle %2 !== 0){
            height *= 2;
        }else{
            height++;
        }
    }
    return height;
}