6e2868de3e
I found a bajillion more tests in the Zend repo, and I'm going to have to namespace things. I think this solution will also be nice for the porting our C++ strings. One directory per package and then when you want to run them all you run the top-level.
20 linhas
316 B
PHP
20 linhas
316 B
PHP
<?php
|
|
|
|
# Compute the n'th Fibonacci number recursively, where n >= 0.
|
|
function fib($n) {
|
|
if ($n > 1) {
|
|
return fib($n-2) + fib($n-1);
|
|
} else {
|
|
return $n;
|
|
}
|
|
}
|
|
|
|
function tail_recurse($n) {
|
|
if ($n > 0) {
|
|
tail_recurse($n-1);
|
|
}
|
|
print $n; print ": "; print fib($n); print "\n";
|
|
}
|
|
|
|
tail_recurse(35);
|