1.

Write a program to print the Fibonacci series. ( Fibonacci series:- 0,1,1,2,3,5,8,13,21…….)plz answer me​

Answer»

Answer:

The given co‎de is written in Java.

import java.util.*;

public class Main   {

   public static VOID main(String args[])  {

       Scanner sc=new Scanner(System.in);

       INT a=1,b=0,c=0,n,i;

       System.out.print("ENTER limit: ");

       n=sc.nextInt();

       for(i=1;i<=n;i++)   {

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

           c=a+b;

           a=b;

           b=c;

       }

       sc.close();

   }

}

Interesting facts about this series:

  • The FIBONACCI series is a series of numbers where each term in the sequence is equal to sum of previous two terms.
  • The first terms are 0 and 1. So, the next term will be 1.
  • Every 3rd term in this sequence is a multiple of 2.
  • Every 4th term is a multiple of 3.
  • Every 5th term is a multiple of 5 and so on.

Refer to the attachment for output.

•••♪



Discussion

No Comment Found