Skip to content

Commit

Permalink
Fibonacci without third variable
Browse files Browse the repository at this point in the history
  • Loading branch information
LathaMurugan-code authored Apr 3, 2021
1 parent 7223a15 commit 696ceb8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions FibonacciOther.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package practice;

public class FibonacciOther {

public static void main(String[] args) {
// TODO Auto-generated method stub
FibonacciOther fn = new FibonacciOther();
fn.findFibonacci1();
}

public void findFibonacci1() {
// TODO Auto-generated method stub
int first = -1;
int second = 1;
int count = 0;
while(count<=10)
{
second = first+second;
first = second-first;
count++;
System.out.println(second+first);
}
}

}

0 comments on commit 696ceb8

Please sign in to comment.