Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active August 17, 2020 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/bcc31dc45b2363b44e5e0f1b953458ab to your computer and use it in GitHub Desktop.
Save lbvf50mobile/bcc31dc45b2363b44e5e0f1b953458ab to your computer and use it in GitHub Desktop.
Just PHP FUN 078.
<?php
# https://www.codewars.com/kata/556deca17c58da83c00002db Tribonacci Sequence.
function tribonacci($signature, $n) {
if(0 == $n) return [];
$ans = $signature;
if($n < 4) return array_slice($ans,0,$n);
for($i = 3; $i < $n; $i += 1) array_push($ans, $ans[$i-1] + $ans[$i-2] + $ans[$i-3]);
return $ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment