Java Program on Fibonacci Series
- Categories Java
Write a program to print Fibonacci series of n numbers.
import java.util.Scanner; public class FibonacciSeries { public static void main(String args[]) { int a = 0,b = 1,c,i; System.out.println("Enter the number:"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(i = 1;i<= n;i++) { System.out.print (a+" "); c = a+b; a = b; b = c; } } }
You may also like
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
28 August, 2021
Constructor Programs
3 July, 2021