from math import log def gamma(n): g=0 for i in range(1,n+1): g+=1/i-log(1+1/i) return g