From 808f45d9e60c125e2a76f9f3f1a65130da72a276 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 4 Jul 2017 21:10:28 +0200 Subject: first sum N --- python/sum-first-n.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 python/sum-first-n.py 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) + -- cgit v1.2.3