Synced the directory structure to that of Python repo

This commit is contained in:
Varun Upadhyay
2017-10-13 06:57:26 -07:00
parent 7dd8fd16cc
commit e53249ba23
25 changed files with 0 additions and 0 deletions

24
Others/FibToN.java Normal file
View File

@@ -0,0 +1,24 @@
import java.util.Scanner;
public class FibToN {
public static void main(String[] args) {
//take input
Scanner scn = new Scanner(System.in);
int N = scn.nextInt();
// print fibonacci sequence less than N
int first = 0, second = 1;
//first fibo and second fibonacci are 0 and 1 respectively
while(first <= N){
//print first fibo 0 then add second fibo into it while updating second as well
System.out.println(first);
int next = first+ second;
first = second;
second = next;
}
}
}