I would like to understand, because I can not mentally glimpse what happens in the excerpt: return fat * factorial.fatorar (fat-1) ;, the question of recursion, regarding the calls of the factorar method itself in relation to multiplication with fat.
public class FatorialRecursiva
{
public static void main(String[] args)
{
FatorialRecursiva fatorial = new FatorialRecursiva();
double dado = 5.0;
dado = fatorial.fatorar(dado);
System.out.print(dado);
}
public double fatorar(double fat)
{
if (fat < 2)
{
return 1;
}else
{
return fat * fatorar(fat-1);
}
}
}