Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function F_recursive($n, $K){
- if($n<=1) {
- return 1;
- } elseif ($K[$n] == 0) {
- $K[$n]=F_recursive($n-1,$K) + F_recursive($n-2,$K);
- }
- return $K[$n];
- }
- function F($n){
- $K=array_fill(0,$n+1,0);
- return F_recursive($n,$K);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement