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)
Programmingway@Eklavya Technosys!: Computer Solutions || Class-4 || Computer for Scho...
Programmingway@Eklavya Technosys!: Computer Solutions || Class-4 || Computer for Scho... : 1) Choose correct one :- 1) The step by step pla...
-
COMPUTER TERMINOLOGY 1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTP...
-
https://makecode.com/_3VxaMo6c3YPp Code 1) What is Make Code Arcade? Answer: Make Code Arcade is a Block based coding. 2) Writ...
-
Check whether the number is negative or positive after taking a number as input from the user. TextWindow . WriteLine ( "Ente...
-
1) ___ is the response of the receiver after perceiving the message. a) Encoding b) Decoding c) Channel d) Feedback 2) Which of the fo...
-
1) Choose correct one :- 1) The step by step plan of solution for solving a problem is called ____. a) Algorithm b) Internet c) URL d) M...
No comments:
Post a Comment