Advertisement
Overfinch

old

Jul 2nd, 2022
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.24 KB | None | 0 0
  1. <?php
  2. function F_recursive($n, $K){
  3.     if($n<=1) {
  4.         return 1;
  5.     } elseif ($K[$n] == 0) {
  6.         $K[$n]=F_recursive($n-1,$K) + F_recursive($n-2,$K);
  7.     }
  8.     return $K[$n];
  9. }
  10.  
  11. function F($n){
  12.     $K=array_fill(0,$n+1,0);
  13.     return F_recursive($n,$K);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement