-

Project Euler problem 1
project euler

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

파이썬 프로젝트 오일러의 1번 문제이다. 10보다 아래인 3과 5의 배수를 모두 합하면 23이다.

1,000 아래의 3과 5의 배수의 합을 구하여라


코드 보기
See Code

x = 0
for n in range(1000):
if n % 3 ==0 or n % 5 ==0:
x += n

print(x)

다른 카테고리의 글 목록

카테고리 없음 카테고리의 포스트를 톺아봅니다