Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C Online

import java.util.Scanner;
public class Fibonacci
{
    public static void main(String args[])
    {
        System.out.println("Enter a number:");
        Scanner Scan=new Scanner(System.in);
        int n=Integer.parseInt(s.nextInt());
        int a=-1;
        int b=1;
        int c=0;
        System.out.println("The fibonacci series are:");
        for(i=1;i<=n;i++)
        {
            c=a+b;
            int temp=a;
            a=b;
            b=c;
            System.out.println(c);
        }
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.