Skip to content

Commit 55afe52

Browse files
committed
Calculate nth Fibonacci Number
1 parent 9f023f4 commit 55afe52

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎src/Assignments/Fibonnaci.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Assignments;
2+
3+
import java.util.Scanner;
4+
5+
public class Fibonnaci {
6+
public static void main(String[] args) {
7+
Scanner input = new Scanner(System.in);
8+
int number = input.nextInt();
9+
10+
int firstNo = 0;
11+
int secondNo = 1;
12+
13+
int count = 2;
14+
15+
while (count <= number){
16+
int temp = secondNo;
17+
18+
secondNo = firstNo + secondNo;
19+
firstNo = temp;
20+
count ++;
21+
}
22+
System.out.println(secondNo);
23+
System.out.println(secondNo);
24+
}
25+
}

‎src/Assignments/Problems.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ public class Problems {
1313

1414
public static void main(String[] args) {
1515

16-
problems.getCurrencyinDollars();
16+
problems.getCurrencyInDollars();
1717
// problems.findLargestNumber();
1818
// problems.calculateSimpleInterest();
1919
// problems.computeWithFormula();
2020
}
2121

22-
void getCurrencyinDollars(){
22+
void getCurrencyInDollars(){
2323

2424
Scanner firstInput = new Scanner(in);
2525
out.println("Enter Rupees: ");

0 commit comments

Comments
 (0)