summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/sum-first-n.py10
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)
+