일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- es6
- 함수
- 최적화
- react
- JavaScript
- gitCLI
- API
- AI
- ES6+
- CSS
- JS
- 햇소
- learn next.js
- This
- html5
- DOM
- next.js
- Python
- 우아한테코톡
- hatso
- dev
- hooks
- github
- ES5+
- 변수
- object
- 선택자
- git
- developerlife
- array
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