We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static int viralAdvertising(int n) {
// Write your code here
int a = 0;
int b = 5;
for(int i = 1; i <= n; i++ ){
int liked = b /2;
a += liked;
b = liked * 3;
}
return a;
}
Cookie support is required to access HackerRank
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 →
public static int viralAdvertising(int n) { // Write your code here int a = 0; int b = 5; for(int i = 1; i <= n; i++ ){ int liked = b /2; a += liked; b = liked * 3; } return a;