Size: 793
Comment:
|
Size: 2420
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
#acl AdminGroup:read,write,delete,revert,admin TadashiIijima:read,write,delete,revert,admin IijimaStaffGroup: IijimaGroup: IijimaObogGroup: GuestGroup: Known: All: | #acl AdminGroup:read,write,delete,revert,admin TadashiIijima:read,write,delete,revert,admin IijimaStaffGroup: IijimaGroup: IijimaObogGroup: GuestGroup: Known: All:read |
Line 12: | Line 12: |
* この例題のポイント: | * この例題のポイント: [[https://docs.python.jp/3/library/math.html|mathモジュール]]の[[https://docs.python.jp/3/library/math.html#math.gcd|gcd()]]関数 |
Line 14: | Line 14: |
||例題(9) ||[[Python/Prog/Example/02/Ex_009a|]]|| || | ||<|3>例題(9)||<|3> 【組込関数】||<|1>[[https://ja.wikipedia.org/wiki/最大公約数|最大公約数]] gcd (greatest common divisor)|| ||<|1> [[https://docs.python.jp/3/library/math.html|mathモジュール]]の[[https://docs.python.jp/3/library/math.html#math.gcd|gcd()]]関数を利用する|| ||<|1> [[Python/Prog/Example/02/Ex_009a|Ex_02_009a_greatest_common_divisor_builtin.py]]|| |
Line 19: | Line 21: |
import math | |
Line 20: | Line 23: |
print( math.gcd( 350, 450 ) ) | |
Line 26: | Line 30: |
#!/usr/bin/env python # -*- coding: utf-8 -*- # ============================================================================== # * Copyright (c) 2018 IIJIMA, Tadashi # * (IIJIMA Laboratory, Dept. of Science and Technology, Keio University). # ============================================================================== # ソフトウェア工学[02] 例題[02]-(009a) Ex_02_009a_greatest_common_divisor_builtin.py # Ex(Example) 02-009a: 【組込関数】 最大公約数 gcd ( greatest common divisor )の使い方. # Python 3.3から導入された. # 2018-10-03 飯島 正 (iijima@ae.keio.ac.jp) # ============================================================================== # ----- 数学関数を扱うためのmathモジュールをインポートする ----- import math # ============================================================================== # ===== 【メイン・プログラム】 ===== print( math.gcd( 350, 450 ) ) # ============================================================================== |
例題(9)
例題(9)
【組込関数】
最大公約数 gcd (greatest common divisor)
- プログラムの本質的な部分は,下記の 行です.
- 例題ファイルとしては,コメントを付け加えた,下記を配布します.
- コメントはもう少し増えるかもしれません.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # ==============================================================================
4 # * Copyright (c) 2018 IIJIMA, Tadashi
5 # * (IIJIMA Laboratory, Dept. of Science and Technology, Keio University).
6 # ==============================================================================
7 # ソフトウェア工学[02] 例題[02]-(009a) Ex_02_009a_greatest_common_divisor_builtin.py
8 # Ex(Example) 02-009a: 【組込関数】 最大公約数 gcd ( greatest common divisor )の使い方.
9 # Python 3.3から導入された.
10 # 2018-10-03 飯島 正 (iijima@ae.keio.ac.jp)
11 # ==============================================================================
12 # ----- 数学関数を扱うためのmathモジュールをインポートする -----
13 import math
14 # ==============================================================================
15 # ===== 【メイン・プログラム】 =====
16 print( math.gcd( 350, 450 ) )
17 # ==============================================================================