The Violence of Compound Interest: Learn a Little Every Day

def a(f, n):
    sum = 1
    if n == 0:
        return sum
    else:
        return "%.2f" % (sum + f) ** n

for i in range(100):
    print i, a(0.1, i)
0 1
1 1.10
2 1.21
3 1.33
4 1.46
5 1.61
6 1.77
7 1.95
8 2.14
9 2.36
10 2.59
11 2.85
12 3.14
13 3.45
14 3.80
15 4.18
16 4.59
17 5.05
18 5.56
19 6.12
20 6.73
21 7.40
22 8.14
23 8.95
24 9.85
25 10.83
26 11.92
27 13.11
28 14.42
29 15.86
30 17.45
31 19.19
32 21.11
33 23.23
34 25.55
35 28.10
36 30.91
37 34.00
38 37.40
39 41.14
40 45.26
41 49.79
42 54.76
43 60.24
44 66.26
45 72.89
46 80.18
47 88.20
48 97.02
49 106.72
50 117.39
51 129.13
52 142.04
53 156.25
54 171.87
55 189.06
56 207.97
57 228.76
58 251.64
59 276.80
60 304.48
61 334.93
62 368.42
63 405.27
64 445.79
65 490.37
66 539.41
67 593.35
68 652.68
69 717.95
70 789.75
71 868.72
72 955.59
73 1051.15
74 1156.27
75 1271.90
76 1399.08
77 1538.99
78 1692.89
79 1862.18
80 2048.40
81 2253.24
82 2478.56
83 2726.42
84 2999.06
85 3298.97
86 3628.87
87 3991.75
88 4390.93
89 4830.02
90 5313.02
91 5844.32
92 6428.76
93 7071.63
94 7778.80
95 8556.68
96 9412.34
97 10353.58
98 11388.94
99 12527.83

Guess you like

Origin blog.csdn.net/dqchouyang/article/details/126652409