Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.
Telegram Channel - https://t.me/codexelltech
import java.util.Scanner;
public class FibRecursion
{
public static void main(String args[])
{
int maxNumber=0;
int preNumber=0;
int nextNumber=1;
System.out.println("How many numbers you want in Fibonacci Series:");
Scanner s= new Scanner(System.in);
maxNumber=s.nextInt();
System.out.println("Fibonacci series of "+maxNumber+" numbers:");
for(int i=1; i<= maxNumber; i++)
{
System.out.println(" "+preNumber);
int sum=preNumber + nextNumber;
preNumber = nextNumber;
nextNumber = sum;
}
}
}
Output:
How many numbers you want in Fibonacci series:
10
Fibonacci series of 10 numbers:
0 1 1 2 3 5 8 13 21 3
Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.
Telegram Channel - https://t.me/codexelltech
Click here to visit www.codexell.tech for more such references.
Telegram Channel - https://t.me/codexelltech
import java.util.Scanner;
public class FibRecursion
{
public static void main(String args[])
{
int maxNumber=0;
int preNumber=0;
int nextNumber=1;
System.out.println("How many numbers you want in Fibonacci Series:");
Scanner s= new Scanner(System.in);
maxNumber=s.nextInt();
System.out.println("Fibonacci series of "+maxNumber+" numbers:");
for(int i=1; i<= maxNumber; i++)
{
System.out.println(" "+preNumber);
int sum=preNumber + nextNumber;
preNumber = nextNumber;
nextNumber = sum;
}
}
}
Output:
How many numbers you want in Fibonacci series:
10
Fibonacci series of 10 numbers:
0 1 1 2 3 5 8 13 21 3
Click Here To Follow our Telegram Channel for more such news and amazing free stuffs.
Telegram Channel - https://t.me/codexelltech
Click here to visit www.codexell.tech for more such references.