You are viewing a single comment's thread. Return to all comments →
Very cool. Here's my non-recursive JavaScript solution:
const halfRoundedDown = (num) => Math.floor(num / 2); function viralAdvertising(n) { let totalLikes = 2; let lastLikes = 2; while (n > 1) { lastLikes = halfRoundedDown(lastLikes * 3); totalLikes += lastLikes; n--; } return totalLikes; }
Seems like cookies are disabled on this browser, please enable them to open this website
Viral Advertising
You are viewing a single comment's thread. Return to all comments →
Very cool. Here's my non-recursive JavaScript solution: