Created
October 13, 2014 08:07
-
-
Save amitchhajer/8617f6c1613ce7b50538 to your computer and use it in GitHub Desktop.
Fibonaaci recursive with 2 variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fibo($n, $first =1, $second=1) | |
{ | |
if($n==1 || $n==2) | |
return $second; | |
else | |
return fibo($n-1, $second,($first + $second)); | |
} | |
echo fibo(6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment