僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。
Rubyの教科書(まだ版元に情報がない)に出ていた、
の累計( (0 * 2 +1) + (1 * 2 +1) + (2 * 2 + 1) + ... (n * 2 + 1)
が、(n + 1) ** 2 になるって話。
import sys last = int(sys.argv[1]) def raising(last): sum = 0 for x in range(last + 1): num = 2 * x + 1 sum += num print(repr(x).rjust(2), repr(num).rjust(5), repr(sum).rjust(4), repr((last + 1)** 2).rjust(10)) print(' n 2n+1 sum (n+1)**2') for x in range(last + 1): raising(x)
$ python3 hoge.py 12 n 2n+1 sum (n+1)**2 0 1 1 1 1 3 4 4 2 5 9 9 3 7 16 16 4 9 25 25 5 11 36 36 6 13 49 49 7 15 64 64 8 17 81 81 9 19 100 100 10 21 121 121 11 23 144 144 12 25 169 169
ftp サイトに入った途端、
ncftp /pub > cd OpenBSD Welcome to ftp.eu.OpenBSD.org Located at the Stockholm University Department of IT & Media For other mirror sites visit http://www.openbsd.org/ftp.html _____ ____ _____ _____ / ___ \ | _ \ / ____| __ \ / / / /___ ___ ____ | |_) | (___ | | | | / / / / __ \/ _ \/ __ \| _ < \___ \| | | | / /__/ / /_/ / __/ / / /| |_) |____) | |__| | \_____/ .___/\___/_/ /_/ |____/|_____/|_____/ /_/ | . The proactively secure Unix-like . |L /| . Operating System. _ . |\ _| \--+._/| . Please visit the OpenBSD web site / ||\| Y J ) / |/| ./ at http://www.openbsd.org/ J |)'( | ` F`.'/ -<| F __ .-< All transfers are logged, if you don't | / .-'. `. /-. L___ like this policy, disconnect now! J \ < \ | | O\|.-' _J \ .- \/ O | | \ |F '-F -<_. \ .-' `-' L__ __J _ _. >-' )._. |-' You can order OpenBSD CDROMs `-|.' /_. \_| F from http://www.openbsd.org/orders.html. /.- . _.< CD sales are important to support the /' /.' .' `\ continued development of the project. /L /' |/ _.-'-\ /'J ___.---'\| |\ .--' V | `. ` |/`. `-. `._) / .-.\ VK \ ( `\ `.\ Directory successfully changed.
リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。