Fibonacci Series Program
For other basic java program click the given link. https://wordpress-343193-1101484.cloudwaysapps.com/solved-programs-class-9-beginner
Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987 ..more
Write a program to print the Fibonacci series. Accept a number from the user and print the Fibonacci series up to that number.
For other basic java program click the given link.
Solved Programs (class 9-Beginner Level)
// series of numbers in which each number is the sum of the two preceding //numbers.0,1, 1, 2, 3, 5, 8.....
import java.io.*;
class fibonacci
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of your choice");
int n=Integer.parseInt(br.readLine());
int a=0,b=1;
int sum=0;
System.out.print(a+",");
System.out.print(b);
while(a+b<=n)
{
sum=a+b;
System.out.print(","+sum);
a=b;
b=sum;
}
System.out.println();
}
}Output:Enter a number of your choice
5
0,1,1,2,3,5
To learn how to install Bluej watch the video https://youtu.be/i845Tz5_QXU
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.