Skip to content

Commit 13cc52a

Browse files
committed
任意整数的几何级数
1 parent 12a1d06 commit 13cc52a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
68.8 KB
Loading
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
# @Time : 2019/5/814:42
4+
5+
__author__ = 'aaronwa'
6+
7+
def geometricprogression(a, q, n):
8+
if q == 1:
9+
sn = a * n
10+
else:
11+
sn = int(a*(q**n-1)/(q-1))
12+
print (sn)
13+
geometricprogression(2, 3, 4)

0 commit comments

Comments
 (0)