[go: up one dir, main page]

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

1.write A Program in JAVA To Display The Fibonacci Series

This Java program displays the Fibonacci series by taking input for the first two numbers, adding them, and then recursively adding the last two numbers to generate the next number in the series. It prints the first two numbers entered by the user, then prints the subsequent generated numbers until it reaches 8 numbers in the series, and ends by printing "THANK YOU".
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views2 pages

1.write A Program in JAVA To Display The Fibonacci Series

This Java program displays the Fibonacci series by taking input for the first two numbers, adding them, and then recursively adding the last two numbers to generate the next number in the series. It prints the first two numbers entered by the user, then prints the subsequent generated numbers until it reaches 8 numbers in the series, and ends by printing "THANK YOU".
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.Write a program in JAVA to display the Fibonacci Series.

import java.io.*;

public class fibonacci

public static void main(String args [])throws IOException

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

System.out.println("THIS PROGRAM IS TO GENERATE 10 VALUES OF FIBONACCI SERIES.");

System.out.println("Enter the values of a");

int a=Integer.parseInt(in.readLine());

System.out.println("Enter the values of b");

int b=Integer.parseInt(in.readLine());

int c,n;

c=0;

n=0;

System.out.println("The fibonnaci series is");

System.out.println("a");

System.out.println("b");

do

c=a+b;

System.out.println(c);

a=b;
b=c;

n=n+1;

while(n<8);

System.out.println("THANK YOU");

OUTPUT
THIS PROGRAM IS TO GENERATE 10 VALUES OF FIBONACCI SERIES.

Enter the values of a

23

Enter the values of b

32

The fibonnaci series is

55

87

142

229

371

600

971

1571

THANK YOU

You might also like