hey guys, i have a project due tomorrow on recursion. the task was to write a recursive program that prints the value of fibonacci numbers and the number of calls made. i wrote the program and it returns the value at the end just fine, but i have been unable to put in a counter to keep track of the calls without different errors. can anybody pleasee help? also, the second part of the project involves memoization, making an array and storing the values that have been calculated already. the program will then look up if the values are stored and return them, it too should have a counter. heres the code
import java.util.Scanner;
public class Fib
{
public static void main(String[] args)
{
int fib;
int n;
Scanner scan = new Scanner(System.in);
System.out.println("input a number");
n = scan.nextInt();
System.out.println("result: " + calcFib(n) + " calls: ");
}
int count = 0;
public static int calcFib (int n)
{
if (n<2)
{
int ans = n;
return ans;
}
else
{
int ans = calcFib(n-1) + calcFib(n-2);
return ans;
}
}
}