aboutsummaryrefslogtreecommitdiff
path: root/challenge-089/ash/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-12-06 11:28:41 +0000
committerGitHub <noreply@github.com>2020-12-06 11:28:41 +0000
commite1fa520a5aee78c1d8c6daaaa232216183047ec8 (patch)
tree7f490b425e24c13a87a34a9a5c15b8b3ae2d142b /challenge-089/ash/python/ch-1.py
parent37f7a8fdda722a8df258f11676317dfa9b4eabba (diff)
parentb0f91205a62dd4131e60d6ce1a8947cfe04b76a2 (diff)
downloadperlweeklychallenge-club-e1fa520a5aee78c1d8c6daaaa232216183047ec8.tar.gz
perlweeklychallenge-club-e1fa520a5aee78c1d8c6daaaa232216183047ec8.tar.bz2
perlweeklychallenge-club-e1fa520a5aee78c1d8c6daaaa232216183047ec8.zip
Merge pull request #2915 from ash/master
Week 89 Task 1 and an Advent blog post
Diffstat (limited to 'challenge-089/ash/python/ch-1.py')
-rw-r--r--challenge-089/ash/python/ch-1.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-089/ash/python/ch-1.py b/challenge-089/ash/python/ch-1.py
new file mode 100644
index 0000000000..b962d9c617
--- /dev/null
+++ b/challenge-089/ash/python/ch-1.py
@@ -0,0 +1,14 @@
+# Test run:
+# $ python3 ch-1.py 100
+# 13015
+
+import sys, math
+
+n = 3 if len(sys.argv) == 1 else int(sys.argv[1])
+
+s = 0
+for x in range(1, n + 1):
+ for y in range(x + 1, n + 1):
+ s += math.gcd(x, y)
+
+print(s)