728x90
반응형
아래 글은 정답이 아니다.
하지만 근접한 방법이라서 남겨본다.
생성자 이름은 알고리즘 문제 사이트에서 참고한 것이기 때문에
깊게 생각하지 않아도 된다.
This file contains 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
public class Euler3 { | |
public static void main(String[] args) { | |
euler3(); | |
} | |
public static void euler3(){ | |
//double largestFF = 7.16151937E8; | |
double largestFF = 0; | |
//double num = 600851475143.0; | |
double num = 6857.0; | |
for(double i = 3 ; i < num/2 ; i=i+2 ){ | |
if(num % i == 0){ | |
largestFF=i; | |
System.out.println("결과는 = "+largestFF); | |
num = num/largestFF; | |
} | |
} | |
} | |
} |
728x90
반응형
'Java' 카테고리의 다른 글
콜백(Callback). 알다가도 모르겠구나. (2) | 2017.01.13 |
---|---|
[Java] Abstract 이해하기 (0) | 2016.09.22 |
[Java] 지정한 범위 내에서 특정 숫자가 몇번 들어가는지 세는 방법 (0) | 2016.09.06 |
[Java] 중복없이 여러개 숫자를 출력하기 (0) | 2016.09.06 |
double보다 큰 범주의 수를 관리할 때, BigDecimal (0) | 2016.09.05 |
Comment