Created
November 17, 2015 22:28
-
-
Save biroa/04f4d4b48c21a2447bff to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Created by PhpStorm. | |
* User: biroa | |
* Date: 10/2/2015 | |
* Time: 7:46 AM | |
*/ | |
/** | |
* @param $n | |
* | |
* @return int | |
*/ | |
function fibonacciRecursive($n) | |
{ | |
if ( $n == 0 ) { | |
return 0; | |
} elseif ( $n == 1 ) { | |
return 1; | |
} else { | |
return (fibonacciRecursive($n - 1) + fibonacciRecursive($n - 2)); | |
} | |
} | |
/** | |
* @param $n | |
* | |
* @return int | |
*/ | |
function caller($number) | |
{ | |
echo "Fibonacci series recursive: "; | |
for ( $i = 0; $i < $number; $i++ ) { | |
echo fibonacciRecursive($i) . ' '; | |
} | |
echo "<br><br>"; | |
} | |
caller(10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment