DILEEPKRISHNA
fibanocii
1 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners

program for fibanocii series?

Ads

View Answers

April 21, 2011 at 11:33 AM


Program to generate Fibonacci Series:

import java.util.*;

public class Fibonacci{
public static void main(String[] args) throws Exception {
Scanner input=new Scanner(System.in);
System.out.print("Enter value of n: ");
    int num = input.nextInt();
    int f1=0,f2=0,f3=1;
    for(int i=1;i<=num;i++){
        System.out.println(f3);
        f1=f2;
        f2=f3;
        f3=f1+f2;
    }
}
}









Related Tutorials/Questions & Answers:
fibanocii
fibanocii  program for fibanocii series

Ads

Advertisement