Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8f3e5a

Browse filesBrowse files
authored
Merge pull request TheAlgorithms#563 from rmakynen/master
Updated comments for the Fibonacci sequence
2 parents d33c84f + c75fce1 commit a8f3e5a
Copy full SHA for a8f3e5a

File tree

Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Open diff view settings
Collapse file

‎Others/FibToN.java‎

Copy file name to clipboardExpand all lines: Others/FibToN.java
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
/**
2+
*
3+
* Fibonacci sequence, and characterized by the fact that every number
4+
* after the first two is the sum of the two preceding ones.
5+
*
6+
* Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21,...
7+
*
8+
* Source for the explanation: https://en.wikipedia.org/wiki/Fibonacci_number
9+
*/
10+
111
import java.util.Scanner;
212

313
public class FibToN {
4-
514
public static void main(String[] args) {
615
//take input
716
Scanner scn = new Scanner(System.in);
817
int N = scn.nextInt();
9-
// print fibonacci sequence less than N
18+
// print all Fibonacci numbers that are smaller than your given input N
1019
int first = 0, second = 1;
11-
//first fibo and second fibonacci are 0 and 1 respectively
1220
scn.close();
1321
while(first <= N){
1422
//print first fibo 0 then add second fibo into it while updating second as well

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.