commit 9a0c416006badc01f4790aee1e25cb13c894eb0f
parent 5bb42f4e2755debb7434d1b90db3d53169ce5df8
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Tue, 30 May 2017 10:50:11 +0200
python
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/calc.py b/calc.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+
+import sys
+from math import gcd
+from functools import reduce
+
+n = int(sys.argv[1])
+
+def lcm(x, y):
+ return x * y // gcd(x, y)
+
+v = []
+v.append(1)
+for i in range(n+1):
+ mylcm = reduce(lcm, v, 1)
+ v.insert(0, 0)
+ for i in range(len(v)):
+ v[i] += mylcm
+
+print(v)
+