Skip to content

Commit

Permalink
Fibonacci series
Browse files Browse the repository at this point in the history
for loop used
  • Loading branch information
suhanigupta23 authored Jan 27, 2024
1 parent 6a23205 commit 94c8482
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Fibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//Printing N numbers of Fibonacci series
import java.util.*;
public class Program
{
public static void main(String[] args)
{
Scanner scn=new Scanner(System.in);
System.out.println("Enter the number of terms required for the Fibonacci series:");
int n=scn.nextInt();
System.out.println("0");
System.out.println("1");
int a=0;
int b=1;
for (int i=1;i<=n-2;i++)
{
int c=a+b;
System.out.println(c);
a=b;
b=c;
}

}

0 comments on commit 94c8482

Please sign in to comment.