📌  相关文章
📜  javascript 代码示例中的病毒式广告hackerrank 解决方案

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

代码示例1
// Viral Advertising hackerrank solution in javascript
function viralAdvertising(n) {
    // Write your code here
    let like = 2;
    let cumulative = 2;
    let day = 0;
    for(let i = 2; i<=n; i++){
        day = like * 3;
        like = Math.floor(day/2);
        cumulative += like;
    }
    return cumulative;
}