반응형
1 ~ 10 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 2520입니다.
그러면 1 ~ 20 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 얼마입니까?
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
#python3 | |
def is_devidable(num_todo, num_to_devide): | |
return num_todo % num_to_devide == 0 | |
def is_devidable_at_range(num_todo,range_from, range_to ): | |
result = True | |
for i in range(range_from, range_to): | |
if not is_devidable(num_todo, i): | |
result = False | |
break | |
return result | |
def find_devidable_min_value(range_from, range_to) : | |
num_todo = range_to | |
while True : | |
if num_todo % range_to == 0 : | |
if not is_devidable_at_range(num_todo, range_from, range_to) : | |
print(num_todo) | |
else : | |
break | |
num_todo += range_to | |
return num_todo | |
print(find_devidable_min_value(1, 20)) |
반응형
'개발 > 알고리즘 문제' 카테고리의 다른 글
[Project Euler 07] 10001번째의 소수 (0) | 2016.03.01 |
---|---|
[Project Euler 06] 1부터 100까지 "제곱의 합"과 "합의 제곱"의 차는? (0) | 2016.03.01 |
[Project Euler 04] 세자리 수를 곱해 만들 수 있는 가장 큰 대칭수 (0) | 2016.03.01 |
[Project Euler 03] 가장 큰 소인수 구하기 (0) | 2016.03.01 |
[Project Euler 02] 피보나치 수열에서 4백만 이하이면서 짝수인 항의 합 (0) | 2016.02.17 |
댓글