Size: 2236
Comment:
|
← Revision 12 as of 2018-10-28 12:38:24 ⇥
Size: 424
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 11: | Line 11: |
[ <<Action(edit)>> ] <<TableOfContents>> [[../Ex_009a/Contents|*]] |
|
Line 12: | Line 15: |
* この例題のポイント: mathモジュールのgcd()関数 ||<|3>例題(9)||<|3> 【組込関数】||<|1>[[https://ja.wikipedia.org/wiki/最大公約数|最大公約数]] gcd ( greatest common divisor )|| ||<|1> mathモジュールのgcd()関数を利用する|| ||<|1> [[Python/Prog/Example/02/Ex_009a|Ex_02_009a_greatest_common_divisor_builtin.py]]|| * プログラムの本質的な部分は,下記の 行です. * {{{#!highlight python import math print( math.gcd( 350, 450 ) ) }}} * 例題ファイルとしては,コメントを付け加えた,下記を配布します. * コメントはもう少し増えるかもしれません. {{{#!highlight python #!/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 ) ) # ============================================================================== }}} * [[attachment:Python/Prog/Example/02/xxxx|xxxx]] |
<<Include(../Ex_009a/Contents)>> [[../Ex_009a/Contents|*]] |