Skip to content

Commit c75fce1

Browse files
author
rmakynen
committed
Updated comments for the Fibonacci sequence
1 parent efae9fb commit c75fce1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Others/FibToN.java

Lines 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)