正剧开始:
星历2016年02月19日 16:32:09, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究数与形。
其实这就是找规律啊,小伟对于找规律是最有兴趣的了。
<span style="font-size:18px;">>>> 1+3+5+7+9 = 25 = 5 * 5 1+3+5+7+9+11 = 36 = 6 * 6 1+3+5+7+9+11+13 = 49 = 7 * 7 1+3+5+7+9+11+13+15 = 64 = 8 * 8 1+3+5+7+9+11+13+15+17 = 81 = 9 * 9 def tmp(): begin = 1; end = 10; s = ''; total = 0; for j in range(10, 20, 2): begin = 1; end = j; s = ''; total = 0; for i in range(begin, end, 2): s += str(i)+'+'; total += i; sqr = int(math.sqrt(total)); print('{0} = {1} = {2} * {2}'.format(s[:-1], total, sqr, sqr)); return;</span>
<span style="font-size:18px;">>>> 1/4+1/8 = 3/4 1/4+1/8+1/16 = 7/8 1/4+1/8+1/16+1/32 = 15/16 1/4+1/8+1/16+1/32+1/64 = 31/32 1/4+1/8+1/16+1/32+1/64+1/128 = 63/64 1/4+1/8+1/16+1/32+1/64+1/128+1/256 = 127/128 1/4+1/8+1/16+1/32+1/64+1/128+1/256+1/512 = 255/256 1/4+1/8+1/16+1/32+1/64+1/128+1/256+1/512+1/1024 = 511/512 1/4+1/8+1/16+1/32+1/64+1/128+1/256+1/512+1/1024+1/2048 = 1023/1024 def tmp(): a = []; b = 2; c = Fraction(1, b); s = ''; for j in range (1, 10): a = []; b = 2; c = Fraction(1, b); s = ''; for i in range(j+1): a.append(c); b*=2; c = Fraction(1, b); s += str(c)+'+'; print(s[:-1], ' = ', sum(a)); return; </span>
这应该就是傅立叶级数以及极限的最初的露面了,其实[人叫板老师]是比较阴险的, 不算极限的话,上面这个算式不可能是1。
<span style="font-size:18px;">>>> 1 = 1 = 2(1*1)-1 1+3+1 = 5 = 2(2*2)-3 1+3+5+3+1 = 13 = 2(3*3)-5 1+3+5+7+5+3+1 = 25 = 2(4*4)-7 1+3+5+7+9+7+5+3+1 = 41 = 2(5*5)-9 1+3+5+7+9+11+9+7+5+3+1 = 61 = 2(6*6)-11 1+3+5+7+9+11+13+11+9+7+5+3+1 = 85 = 2(7*7)-13 1+3+5+7+9+11+13+15+13+11+9+7+5+3+1 = 113 = 2(8*8)-15 1+3+5+7+9+11+13+15+17+15+13+11+9+7+5+3+1 = 145 = 2(9*9)-17 def tmp(): begin = 1; end = 10; s = ''; total = 0; for j in range(2, 20, 2): begin = 1; end = j; s = ''; total = 0; for i in range(begin, end, 2): s += str(i)+'+'; total += i; for i in range(end-3, begin-1, -2): s += str(i)+'+'; total += i; print('{0} = {1} = 2({2}*{2})-{3}'.format(s[:-1], total, end//2, end-1)); return;</span>
<span style="font-size:18px;">>>> 1 --> red: 1 blue: 8 2 --> red: 2 blue: 10 3 --> red: 3 blue: 12 4 --> red: 4 blue: 14 5 --> red: 5 blue: 16 6 --> red: 6 blue: 18 7 --> red: 7 blue: 20 8 --> red: 8 blue: 22 9 --> red: 9 blue: 24 10 --> red: 10 blue: 26 11 --> red: 11 blue: 28 12 --> red: 12 blue: 30 13 --> red: 13 blue: 32 14 --> red: 14 blue: 34 def tmp(): for n in range(1, 15): red = n; blue = (n+2)*3-n; print(n, ' --> ', 'red:', red, 'blue:', blue); return; </span>
<span style="font-size:18px;">>>> 1 --> 8 2 --> 16 3 --> 24 4 --> 32 5 --> 40 6 --> 48 7 --> 56 8 --> 64 9 --> 72 10 --> 80 11 --> 88 12 --> 96 13 --> 104 14 --> 112 >>> #题1 def tmp(): for n in range(1, 15): a = (2*n+1)*(2*n+1)- (2*n-1)*(2*n-1); print(n, ' --> ',a); return;</span>
<span style="font-size:18px;">>>> 1 --> 1 2 --> 3 3 --> 6 4 --> 10 5 --> 15 6 --> 21 7 --> 28 8 --> 36 9 --> 45 10 --> 55 11 --> 66 12 --> 78 13 --> 91 14 --> 105 #题2 def tmp(): a = [] for n in range(1, 15): a.append(n); print(n, ' --> ',sum(a)); return;</span>
<span style="font-size:18px;">>>> 1 --> n: 1 C: 3 4 --> n: 4 C: 6 9 --> n: 9 C: 9 16 --> n: 16 C: 12 25 --> n: 25 C: 15 36 --> n: 36 C: 18 49 --> n: 49 C: 21 64 --> n: 64 C: 24 81 --> n: 81 C: 27 100 --> n: 100 C: 30 121 --> n: 121 C: 33 144 --> n: 144 C: 36 169 --> n: 169 C: 39 196 --> n: 196 C: 42 #题3 def tmp(): n = 0; for i in range(1, 15): n += (2*i-1); C = 3*i; print(n, ' --> ','n:', n, 'C:', C); return;</span>
<span style="font-size:18px;">>>> [1] [1, 1] [1, 2, 1] [1, 3, 3, 1] [1, 4, 6, 4, 1] [1, 5, 10, 10, 5, 1] [1, 6, 15, 20, 15, 6, 1] [1, 7, 21, 35, 35, 21, 7, 1] [1, 8, 28, 56, 70, 56, 28, 8, 1] [1, 9, 36, 84, 126, 126, 84, 36, 9, 1] #题7 def tmp(): res = [[1]]; n = 10; width = n*3; for i in range(1, n): a = []; for j in range(i+1): if (j == 0 or j == i): a.append(res[i-1][0]); else: a.append(res[i-1][j-1]+res[i-1][j]); res.append(a); for i in range(n): print('{0:^{w}}'.format(res[i], w=width)); return;</span>
本节到此结束,欲知后事如何,请看下回分解。