Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
13
Task/Anonymous-recursion/PHP/anonymous-recursion-1.php
Normal file
13
Task/Anonymous-recursion/PHP/anonymous-recursion-1.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
function fib($n) {
|
||||
if ($n < 0)
|
||||
throw new Exception('Negative numbers not allowed');
|
||||
else if ($n < 2)
|
||||
return 1;
|
||||
else {
|
||||
$f = __FUNCTION__;
|
||||
return $f($n-1) + $f($n-2);
|
||||
}
|
||||
}
|
||||
echo fib(8), "\n";
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue