Java Program fibbonicci series using recursion
import java.util.*;
class fibseries
{
public static void main(String args[])
{
int n=0;
System.out.println("enter the number limit ");
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
System.out.println("the series is");
int k;
for(int i=1; i<=n; i++)
{
k=fSeries(i);
System.out.println(""+k);
}
}
static int fSeries(int n)
{
if(n==1)
{
return 0;
}
else if (n==2)
{
return 1;
}
else if (n>2)
return (fSeries(n-1)+fSeries(n-2));
else
return -1;
}
}
Video/ C Introduction
Watch video in full size