Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Heat Equation
- 이중우선순위큐
- Blasius
- 예제
- 프로그래머스
- 회귀
- Finite Difference Method
- Python
- projecteuler
- 통계학
- Statistics
- Fluid Dynamics
- FTCS
- Fluids
- 우선순위큐
- 파이썬
- programmers
- Boundary Layers
- 유체역학
- Navier-Stokes
- 프로젝트오일러
- heap
- 디스크 컨트롤러
- regression
- Turbulent
- Crank-Nicolson
- Laminar
- Compressible Flow
- 힙
- python3
Archives
- Today
- Total
Sudal's Garage
Project Euler 1 본문
Question:
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.
문제:
0보다 작은 자연수 중에서 3 또는 5의 배수는 3, 5, 6, 9 이고, 이것을 모두 더하면 23입니다.
1000보다 작은 자연수 중에서 3 또는 5의 배수를 모두 더하면 얼마일까요?
Solution:
1 2 3 4 5 6 7 | a = set() for i in range(1000): if i % 3 == 0 or i % 5 == 0: a.add(i) print(sum(a)) | cs |
첫번째 솔루션!
설명이 필요 없다.
이후
1 | print(sum(i for i in range(1000) if i % 3 ==0 or i % 5 == 0)) | cs |
코드를 더 짧게 만들고 싶어 검색을 하던 중 Comprehension 이 떠올라 적용해 봤다.
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 5 (0) | 2019.01.30 |
---|---|
Project Euler 4 (0) | 2019.01.30 |
Project Euler 3 (0) | 2019.01.30 |
Project Euler 2 (0) | 2019.01.30 |
Project Euler (0) | 2019.01.30 |