0% found this document useful (0 votes)
23 views2 pages

Fibbo

This Java code uses a for loop to print out the Fibonacci series up to a number entered by the user, by initializing two variables to track the previous two numbers and adding them together to get the next number in the series on each iteration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Fibbo

This Java code uses a for loop to print out the Fibonacci series up to a number entered by the user, by initializing two variables to track the previous two numbers and adding them together to get the next number in the series on each iteration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;
class Fibb
{
public static void main(String args[])

{
Scanner sc=new Scanner(System.in);
System.out.println(" ");
System.out.println("Enter the no.of.series");
int a=0,b=1,c,d;
d=sc.nextInt();

System.out.println(" ");
System.out.println("Fibonacci series");
System.out.println(" ");
for(int i=1;i<=d;i++)
{
System.out.println(a+ " ");

c=a+b;
a=b;
b=c;
}
}
}

You might also like