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