public class Interaction {
public static void main(String[] args) {
int n = 4;
f(n);
}
public static int f(int n) {
if (n <= 2) {
n++;
System.out.println(n);
return n; // Add this return statement
} else {
int result = f(n - 1) * f(n - 2) + f(n - 2);
System.out.println("f(" + n + ") = " + result);
return result; // Add this return statement
}
}
}
here the code doesnt work without the return statement
