gcd_difference

bruteforce for https://oeis.org/A199768
git clone https://a3nm.net/git/gcd_difference/
Log | Files | Refs

calc.py (300B)


      1 #!/usr/bin/python3
      2 
      3 import sys
      4 from math import gcd
      5 from functools import reduce
      6 
      7 n = int(sys.argv[1])
      8 
      9 def lcm(x, y):
     10     return x * y // gcd(x, y)
     11 
     12 v = []
     13 v.append(1)
     14 for i in range(n-1):
     15     mylcm = reduce(lcm, v, 1)
     16     v.insert(0, 0)
     17     for i in range(len(v)):
     18         v[i] += mylcm
     19 
     20 print(v)
     21