diff options
author | Patrick Simianer <p@simianer.de> | 2017-07-04 21:10:28 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2017-07-04 21:10:28 +0200 |
commit | 808f45d9e60c125e2a76f9f3f1a65130da72a276 (patch) | |
tree | 745ff6d4f8ccf6dfe95066ff274ab0534b0f2266 /python | |
parent | c4bb22f922b409b989b76ecc1126f6f99f0b8170 (diff) |
first sum N
Diffstat (limited to 'python')
-rw-r--r-- | python/sum-first-n.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/python/sum-first-n.py b/python/sum-first-n.py new file mode 100644 index 0000000..7a4edd1 --- /dev/null +++ b/python/sum-first-n.py @@ -0,0 +1,10 @@ +def s(n): + i = n-1 + sum = 0 + while i >= 1: + sum += i + i -= 1 + return sum + +print s(1500) + |