Differences between revisions 3 and 4
Revision 3 as of 2019-10-09 14:56:41
Size: 2215
Comment:
Revision 4 as of 2019-10-09 17:09:22
Size: 2219
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

[ edit ]

  • 例題ファイルとしては,コメントを付け加えた,下記を配布します.
    • コメントはもう少し増えるかもしれません.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ==============================================================================
# * Copyright (c) 2018 IIJIMA, Tadashi
# *       (IIJIMA Laboratory, Dept. of Science and Technology, Keio University).
# ==============================================================================
# ソフトウェア工学[02] 例題[02]-(002a)  Ex_02_002a_mersenne_number.py
# Ex(Example) 02-002a: 【関数定義】 メルセンヌ数を求める関数を定義する. 
#                               n番目のメルセンヌ数は,2の冪よりも 1 小さい自然数,すなわち 2^n − 1. 
#        2018-10-03 飯島 正 (iijima@ae.keio.ac.jp)
# ==============================================================================
# ===== 【関数定義】 n番目のメルセンヌ数 =====
#  ※n番目のメルセンヌ数は,2のn乗-1
def mersenne_number( n ):
    return( 2 ** n - 1 )
# ==============================================================================
# ===== 【メイン・プログラム】  =====
# ----- オープニングメッセージ -----
print( "メルセンヌ数を求めます: " )

# ----- パラメータの入力 -----
n = int( input( "正の整数を入力してください>>> " ) );

# ----- 結果の表示 ----
print( "    ", n, "番目のメルセンヌ数は ", mersenne_number( n ) )

print()
print( "1~", n, "までのメルセンヌ数列", sep="" )
for i in range( 1, n+1 ):
    print( "    ", n, "番目のメルセンヌ数は ", mersenne_number( i ) )
# ==============================================================================

SoftEng: Python/Prog/Example/02/Ex_002a/Distribution (last edited 2019-10-09 17:09:22 by TadashiIijima)