Skip to content

Instantly share code, notes, and snippets.

@halitanildonmez
Created April 15, 2021 17:43
Show Gist options
  • Save halitanildonmez/5e05b4155dbd2a2dfa6cb609dadaea2f to your computer and use it in GitHub Desktop.
Save halitanildonmez/5e05b4155dbd2a2dfa6cb609dadaea2f to your computer and use it in GitHub Desktop.
Solution for "Viral Advertising" at Hackerrank
// Complete the viralAdvertising function below.
static int viralAdvertising(int n) {
int cummulative = 0;
int shared = 5;
for (int day = 1; day <= n; day++) {
int like = shared / 2;
shared = like * 3;
cummulative += like;
}
return cummulative;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment