1package program;
2import java.io.*;
3class fibonacci
4 {
5publicvoidfb(int range)
6 {
7int
first=1,second=-1,fibonacci=0;
8System.out.println("range
of term for fibonacci series"+range);
9
10for (inti=0;i<range;i++)
11 {
12 fibonacci=first+second;
13 second=first;
14 first=fibonacci;
15
16System.out.print(""+fibonacci);
17 }
18
19 }
20 }
21publicclassfibo
22 {
23publicstaticvoid main (String
args[]) throwsIOException
24 {
25int r;
26InputStreamReader input=newInputStreamReader(System.in);
27BufferedReaderbr=newBufferedReader(input);
28System.out.println("enter
number: ");
29 r=Integer.parseInt(br.readLine());
30System.out.println("input
number: "+r);
31 fibonacci obj=newfibonacci();
32obj.fb(r);
33 }
34 }
35
36
|
Output
run:
enter number:
10
input number: 10
range of term for
fibonacci series10
0 1 1 2 3 5 8 13 21 34
|
Computer Science :: 11th/12th, Computer Engineering :: Degree/Diploma, Coding Concept ( C, C++ & JAVA Programming, JDBC Concept, DBMS - SQL Concept, Data Structure, Communication & Network Concept.
Sunday, November 22, 2015
JAVA FIBONACCI SERIES
Subscribe to:
Post Comments (Atom)
JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025
Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...
-
1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTPs - Hyper Text Transfer Protocol. 3) ICT - Information Comunication Te...
-
1) What is Make Code Arcade? Answer: Make Code Arcade is a coding platform that enables to create block – based program. 2) How ...
-
Programmingway@Eklavya Technosys!: New Year's 2025 | Happiness & Healthier's Life Sty... : भारत कई धर्मों का संगम है, हिंदू, मुस...
No comments:
Post a Comment