Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba08647

Browse files
author
shengshijun
committed
用欧几里得算法求解最大公约数
1 parent510b054 commitba08647

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

‎README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ algorithm
3939
###斐波那契树
4040
1. 使用循环实现的算法o(n)
4141

42+
##数论算法
43+
1. 欧几里得算法求解最大公约数
44+
4245

4346
#数据结构
4447
------------

‎number_theory/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'

‎number_theory/gcd.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
# -*- coding:UTF-8
3+
__author__='shenshijun'
4+
5+
6+
defgcd(a,b):
7+
divisor=a
8+
dividend=b
9+
whiledividendisnot0:
10+
divisor,dividend=dividend,divisor%dividend
11+
returndivisor
12+
13+
14+
defmain():
15+
print(gcd(12,18))
16+
17+
18+
if__name__=="__main__":
19+
main()
20+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp