일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- ES5+
- hatso
- 최적화
- API
- 선택자
- git
- ES6+
- JS
- array
- 변수
- github
- dev
- html5
- CSS
- JavaScript
- gitCLI
- hooks
- react
- learn next.js
- es6
- AI
- object
- DOM
- 햇소
- developerlife
- next.js
- 우아한테코톡
- This
- 함수
Archives
- Today
- Total
codinghatso
알고리즘 with python.01 본문
소수 나열하기
input = 20
# 소수는 자기 자신과 1외 에는 아무것도 나눌 수 없다.
def find_prime_list_under_number(number):
prime_list = []
for n in range(2, number + 1): # n의 범위 : 2부터 number까지
for i in prime_list: # i의 범위 : 2부터 n - 1까지
for i in prime_list: # i의 범위 : 2부터 n - 1까지
if n % i == 0 and i * i <= n:
break
else:
prime_list.append(n)
return prime_list
result = find_prime_list_under_number(input)
print(result)
'코테일지' 카테고리의 다른 글
알고리즘 with python.06 (0) | 2021.06.13 |
---|---|
알고리즘 with python.05 (0) | 2021.05.30 |
알고리즘 with python.04 (0) | 2021.05.30 |
알고리즘 with python.03 (0) | 2021.05.30 |
알고리즘 whit python.02 (0) | 2021.05.30 |
Comments