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 |
Tags
- Python DataFrame
- 알고리즘
- 파이썬 전처리
- it 용어
- 리눅스
- HTML
- Python 라이브러리
- RFP
- it용어
- C#
- 파이썬 알고리즘
- 오라클
- Algorithm
- sql
- 코딩테스트
- 리눅스 명령어
- csharp
- linux
- VirtualBox
- putty
- 파이썬 데이터프레임
- 데이터베이스
- 파이썬
- Oracle
- dbeaver
- tibero
- python algorithm
- PYTHON
- MariaDB
- Oracle VM VirtualBox
Archives
- Today
- Total
오경석의 개발노트
Python 알고리즘_1부터 n까지 연속한 숫자의 제곱의 합 본문
# algorithm_1, 계산복잡도 : O(n)
def squared1(n):
result = 0
for i in range(1, n + 1):
result += i * i
return result
# algorithm_2, 계산복잡도 : O(1)
def squared_2(n):
return n * (n + 1) * (2 * n + 1) // 6
'알고리즘 > Python 알고리즘' 카테고리의 다른 글
Python 알고리즘_리스트 최솟값 구하기 (0) | 2022.11.14 |
---|---|
Python 알고리즘_리스트 최댓값 구하기 (0) | 2022.11.14 |
Python 알고리즘_리스트 최댓값의 위치 구하기 (0) | 2022.11.14 |
Python 알고리즘_1부터 n까지의 합 구하기 (0) | 2022.11.09 |
Python 알고리즘_절댓값 구하기 (0) | 2022.11.09 |
Comments