Skip to content

Commit

Permalink
인자가 47이상일때 음수가 출력되는 문제 수정
Browse files Browse the repository at this point in the history
자료형을 int에서 java.math.BigInteger로 수정하여 임의 자리의
값을 처리하도록 수정

Signed-off-by: Jongsoo Lee <[email protected]>
  • Loading branch information
recursivecurry committed Mar 15, 2014
1 parent 9b15239 commit d335260
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Fibonacci.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import java.math.BigInteger;

public class Fibonacci{

public static void main(String []args){
int start = Integer.parseInt(args[0]);
int fib1 = 0;
int fib2 = 1;
BigInteger fib1 = new BigInteger("0");
BigInteger fib2 = new BigInteger("1");
for(int i = 0; i <= (start -2); i++) {
int fib3 = fib1 + fib2;
BigInteger fib3 = fib1.add(fib2);
System.out.println("F"+ i + " = " + fib1 + ", F" + (i+1) + " = " + fib2 + ", F" + (i+2) + " = " + fib3);
fib1 = fib2;
fib2 = fib3;
Expand Down

0 comments on commit d335260

Please sign in to comment.