Computer Science, asked by kalikantroy27, 3 months ago

In JAVA with OUTPUT

Write a program to display the first 10 Fibonacci numbers​

Answers

Answered by anindyaadhikari13
4

Answer:

This is the required Java program for the question.

public class FibonacciSeries    {

   public static void main(String args[])  {

       int a=1,b=0,c=0,i=1;

       for(;i<=10;i++) {

           System.out.print(c+" ");

           c=a+b;

           a=b;

           b=c;

       }

  }

}

Algorithm:

  1. START.
  2. Initialise a=1, b=0, c=0
  3. Iterate loop 10 times.
  4. Display c
  5. Add the sum of a and b and store in c.
  6. Store the value of b in a.
  7. Store the value of c in b.
  8. STOP.

Refer to the attachment.

•••♪

Attachments:
Similar questions