echo viralAdvertising(5)."\n\n";
echo viralAdvertising(10);
/* Day Shared Liked Cumulative 1 5 2 2 2 6 3 5 3 9 4 9 4 12 6 15 5 18 9 24 */ // Determines how many people have liked // the ad by the end of a given day
function viralAdvertising($n) {
	$liked = 2;
	$shared = 0;
	$cumulative = 2;
//Looping through the days
for ($i = 2; $i <= $n; $i++) {
		$shared = $liked*3;
		$liked = floor($shared/2);
		$cumulative += $liked;
	}
	return $cumulative;
}
by ვაჟა ტყემალაძე
2 years ago
PHP
Note
Problem
php
PHP official doc
0
Pro tip: use ```triple backticks around text``` to write in code fences