📅  最后修改于: 2022-03-11 15:02:34.455000             🧑  作者: Mango
// 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;
}