0401프로그래머스#33
Open
platycodonv wants to merge 1 commit into
Open
Conversation
0401프로그래머스 문제 1번,2번
ghost
reviewed
Mar 31, 2022
| if(number == 0) return false; | ||
| if(number == 1) return false; | ||
| if(number == 2) return true; | ||
| for(int i = 3; i<=Math.sqrt(number); i = i+2) { |
ghost
reviewed
Mar 31, 2022
|
|
||
| String sector = ""; | ||
| for(int i = 0; i<change.length();i++) { | ||
| if(change.charAt(i) != '0') sector += change.charAt(i); |
Kuuuna98
reviewed
Mar 31, 2022
| if(number == 0) return false; | ||
| if(number == 1) return false; | ||
| if(number == 2) return true; | ||
| for(int i = 3; i<=Math.sqrt(number); i = i+2) { |
Member
There was a problem hiding this comment.
for문이 반복할 때마다 조건문을 확인하기 때문에, 매번 Math.sqrt() 함수가 실행됩니다
변수로 저장해서 사용하면 sqrt함수 실행을 한번만 하기 때문에 시간적으로 더 좋은 코드가 될 수 있을 거라 생각합니다~~!😺
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

0401프로그래머스 문제 1번,2번