Created
April 15, 2021 17:43
-
-
Save halitanildonmez/5e05b4155dbd2a2dfa6cb609dadaea2f to your computer and use it in GitHub Desktop.
Solution for "Viral Advertising" at Hackerrank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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