Code:public class Fib{ public static void main(String[] args){ calculate(0,0,0,0); } private static void calculate(int f1, int f2,int temp,int counter){ temp = f2; f2 = f1 + f2; f1 = temp; f1 = f1 + 1; System.out.println(f1); counter = counter + 1; if(counter == 10) return; calculate(f1,f2,temp,counter); } }




Reply With Quote