Computer Science, asked by butterflyqueen, 1 year ago

Does anyone knows how to write Fibonacci program in java using buffered class


butterflyqueen: Someome please help me
Anonymous: wait i m helping
butterflyqueen: Ok
butterflyqueen: I'm confused I can't decide whom to mark as brainliest
butterflyqueen: Both the answers are brainliest
siddhartharao77: Hehehehe
Anonymous: PLZ MARK BHAIYA'S ANSWER...
butterflyqueen: Ok

Answers

Answered by Anonymous
5
hey!!

here is ur answer!!


========================

A program is here to print the Fibonacci series 0,1,2,3,4,5......n terms....

class Xyz

static void fibonnaci(int n)

{

    int a = 0;   

    int b = 1;

    int  c;

     System.out.println(a + " " + b);

    int i = 3;

    while(i<=n)

    {

      c= a+ b;
     
      System.out.println(" "+c);

      a = b;
    
      b = c;
   
       }

   }

}

==========================================================

here,

in fibonacci series,

first we take three interger terms in which first one will be 0 and second one will be 1....and the third one will be remains without value.....

now we print the statement and take another another value of integer type for showing the value of n (no of terms)

than we use while statement as we khow in fibonacci  number the third term will equal to the sum of another two i.e c = a+b...

and in fibonacci the first term is equal to the second term and second term is equal to the  first term...

example = 111,555,888, etc....

Hope this helps u!!


butterflyqueen: Thank you
butterflyqueen: Why you are using ing i = 3
Answered by siddhartharao77
6
import java.io.*;
class Brainly
{
public static void main(String args[]) throws IOException
{
System.out.println("Enter the number of elements to be read: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br. readLine());
int b = 0, c = 1, d;
System.out.println("The series is: ");
for(int i = 0; i<a; i++)
{
d=b+c;
b=c;
c=d;
System.out.println(b);
}
}
}


Hope this helps!

siddhartharao77: Gud Luck :-)
butterflyqueen: Thank you
Anonymous: bhaiya now i understand why we use bufferreader...Thanks for ur support,..
Similar questions