wap to check number is fibonacci

import java.util.Scanner;
class Fibonacci 
{
public static void main(String[] args) 
{
int i,no, first=0, second=1, next;
Scanner s=new Scanner(System.in);
System.out.println("Enter number of terms for Series: ");
no=s.nextInt();
first=0;
second=1;
System.out.println("Fibonacci series are: ");
 for(i=0; i<no; i++)
 {
  System.out.println(first);
  next = first + second;
  first = second;
  second = next;
  }
}
}

Comments

Popular posts from this blog

A story of friendship A tiger and a rat......become a revengable....

best pen drive

wap to perform subtraction