I am studying the subject of recursion and I have two doubts that consist of the following:
1 .- I have seen that normally when calling a function within itself it is done through return , something like the following:
return fibonacci(n-1) + fibonacci(n-2);
My question is if it is still considered recursion if you call without a return , for example:
void funcionRecursiva (/*Parámetros*/)
{
//Caso base
if (/*Alguna condicional aquí*/) return;
/*
*
* Codigo
*
*/
funcionRecursiva (/*Parámetros*/);
}
The above function would call itself until a certain condition is met (base case), and if it is not met, it calls itself until it is fulfilled, but does not call itself with a return , does that mean that it does not "count" as recursion?
2 .- If the above does not "count" as recursion, would it count if it changes to something like this ?:
void funcionRecursiva (/*Parámetros*/)
{
//Caso base
if (/*Alguna condicional aquí*/) return;
/*
*
* Codigo
*
*/
return funcionRecursiva (/*Parámetros*/);
}
Is it correct to call a function within itself using a return if that function is of void ?
I appreciate all the help and direction they could give me. Thanks.