Skip to content

Instantly share code, notes, and snippets.

@amitchhajer
Created October 13, 2014 08:07
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 amitchhajer/8617f6c1613ce7b50538 to your computer and use it in GitHub Desktop.
Save amitchhajer/8617f6c1613ce7b50538 to your computer and use it in GitHub Desktop.
Fibonaaci recursive with 2 variables
<?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