Advertisement
NozdrachevNN

task 15

Sep 5th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2. $signature = [2,13,0,12,20,4,5,4,15,9,15,3,17,9,15,10,6,12];
  3. $n = 49;
  4.  
  5. function xbonacci( $signature, $n){
  6. $l = count ($signature);
  7. if ($n == 0) {
  8.     return ($arr=[]);
  9.     }
  10. else {
  11.         while (count ($signature) < $n) {
  12.             $arr = array_slice ($signature, -$l);
  13.             $s = array_sum ($arr);
  14.             $signature[] = $s;
  15.             }
  16.     $output = array_slice($signature, 0, $n);
  17.     return ($output);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement