Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution time 추가 #33 #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Fibonacci.class
Binary file not shown.
34 changes: 24 additions & 10 deletions Fibonacci.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@
public class Fibonacci{

public static void main(String []args){
int start = Integer.parseInt(args[0]);
BigInteger fib1 = new BigInteger("0");
BigInteger fib2 = new BigInteger("1");
for(int i = 0; i <= (start -2); i++) {
BigInteger fib3 = fib1.add(fib2);
System.out.println("F"+ i + " = " + fib1 + ", F" + (i+1) + " = " + fib2 + ", F" + (i+2) + " = " + fib3);
fib1 = fib2;
fib2 = fib3;
}
int size = args.length;
if(args.length==0){
System.out.println("Should insert ags");
System.exit(0);
}
int start = Integer.parseInt(args[0]);
if(start==1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래 for문의 조건에서 i가 start - 2 이기 때문에, start == 2에 대한 조건도 있으면 좋을 것 같습니다.

System.out.println("Why did u insert 1?");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes or no를 입력 받는 부분이 없습니다. alert만 하고 끝내고 싶다면, 종료구문이 없어보입니다.

}else{
System.out.println("Let it Go!!!!!!");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 부부는 불필요한 출력문 같습니다.

}
long startTime = System.currentTimeMillis();
BigInteger fib1 = new BigInteger("0");
BigInteger fib2 = new BigInteger("1");
for(int i = 0; i <= (start -2); i++) {
BigInteger fib3 = fib1.add(fib2);
System.out.println("F"+ i + " = " + fib1 + ", F" + (i+1) + " = " + fib2 + ", F" + (i+2) + " = " + fib3);
fib1 = fib2;
fib2 = fib3;
}
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println("Execution time is " + totalTime);
}
}
}