MiniJavaCompiler/Test/JavaSources/TestRecursion.java
2024-06-14 07:57:38 +02:00

28 lines
449 B
Java

public class TestRecursion {
public int value = 0;
public TestRecursion child = null;
public TestRecursion(int n)
{
value = n;
if(n > 0)
{
child = new TestRecursion(n - 1);
}
}
public int fibonacci(int n)
{
if(n < 2)
{
return n;
}
else
{
return fibonacci(n - 1) + this.fibonacci(n - 2);
}
}
}