You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a problem in the fibonacci function. The fibonacci number is not defined for numbers < 0.
The current function would run in an endless loop (as far as PHP stack count reaches).
function fibonacci(int $n): int
{
if ($n < 0){
throw new Exception('Only positive integer are valid arguments');
}
if ($n === 0 || $n === 1) {
return $n;
}
if ($n >= 50) {
throw new Exception('Not supported');
}
return fibonacci($n - 1) + fibonacci($n - 2);
}
Kind regards and thanks for the inspiring clean-code-php examples.
The text was updated successfully, but these errors were encountered:
There is a problem in the fibonacci function. The fibonacci number is not defined for numbers < 0.
The current function would run in an endless loop (as far as PHP stack count reaches).
Kind regards and thanks for the inspiring clean-code-php examples.
The text was updated successfully, but these errors were encountered: