I have written the Fibonacci series as below. I would like to like to know if the below is the right way of using recursion because I am thinking I am looping the fibonacci function with the condition and incrementing value of i everytime just like a for loop.
public class FibanocciSeriesImpl {
static int a,b,i,n;
static
{
a=0; b=1;i=2;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of elements in the series");
n=sc.nextInt();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("The fibnocci series is below");
System.out.print(a+","+b);
fibnocciImpl(a,b);
}
public static void fibnocciImpl(int a,int b)
{
int c=a+b;
a=b;
b=c;
i++;
System.out.print(","+c);
if(i<n)
fibnocciImpl(a,b);
}
}