Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Monday, February 4, 2019

Fibonacci series programming in java

Hello friends! Welcome to my website

Program to generate Fibonacci series programming in java. How to use for loop in java language with example
In this Fibonacci series, each number is a sum of the previous two numbers. fibonacci series programming java, Fibonacci series java programming, Fibonacci series java code in java session

How to print Fibonacci series programming in java


import java.util.Scanner;
public class fibonacci {
    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);
        long x, y, z;
        int i, n;
        x = 0;
        y = 1;
        System.out.print("Enter the number of terms : ");
        n = c.nextInt();
        System.out.print(y+", ");
        for (i = 1; i < n; i++) {
            z = x + y;
            System.out.print(z+", ");
            x = y;
            y = z;
        }
        System.out.print(" ");
    }
}


Output: Enter the number of terms: 10
        1, 1, 2, 3, 5, 8, 13, 21, 34, 55,


I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this java programming code or input & output please comment below
If you have another question about java programming send an email by contacting us form are given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please any query email programmingshortcut@gmail.com

Please comment your experience on this post,
Thank You!

Programming Shortcut is collections in java best programs with example, best c programs with example and best c++ programs with example, best way to learn java, c and c++

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming