-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
56 lines (39 loc) · 1.03 KB
/
tests.py
File metadata and controls
56 lines (39 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
### 스택과 큐
# from collections import deque
# queue = deque()
# queue.append(5)
# queue.append(2)
# queue.append(3)
# queue.append(7)
# queue.popleft()
# queue.append(1)
# queue.append(4)
# queue.popleft()
# print(queue)
### 재귀 함수
# def recursive_function(i):
# if i == 100: #종료 조건 꼭 넣어줘야함
# return
# print(i, '번쨰 재귀함수에서', i + 1, '번째 재귀 함수를 호출합니다.')
# recursive_function(i + 1)
# print(i, '번째 재귀함수를 종료합니다.')
# recursive_function(1)
### 재귀 함수
def factorial_iterative(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
print('반복적으로 구현:', factorial_iterative(5))
def factorial_reculsive(n):
if n <= 1:
return 1
return n * factorial_iterative(n - 1)
print('반복적으로 구현:', factorial_reculsive(5))
def uclid(a, b):
if a % b == 0:
#print(b)
return b
else:
return uclid(b, a % b)
print(uclid(192, 162))