본문 바로가기

[Project Euler] Problem 005

사실 그냥 눈으로만 봐도 계산기 켜서 2⁴ × 3² × 5 × 7 × 11 × 13 × 17 × 19를 계산하면 된다는 것을 알 수 있다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class Problem005 {
 
    public static void main(String[] args) {
        int dividend = 1;
        
        for(int i = 3; i <= 20++i) {
            if(dividend % i != 0) {
                dividend += (i - 1);
                i = 3;
            }
        }
        
        System.out.println(dividend);
    }
}
cs

정답: 232792560

 

1년 전 쯤에 풀고 주석을 안 써놔서 무슨 생각으로 푼 건지 모르겠다.  

 

*2021/01/16:  https://t0pli.tistory.com/147

'Programming > Solutions' 카테고리의 다른 글

[Project Euler] Problem 007  (0) 2019.03.24
[Project Euler] Problem 006  (0) 2019.03.24
[BAEKJOON] 11721번  (0) 2019.03.20
[Project Euler] Problem 004  (0) 2019.03.20
[Project Euler] Problem 003  (0) 2019.03.19