import decimal import numpy as np from decimal import * getcontext().prec = 1000 def my_factorial (number): facto = Decimal ('1') for n in range (1, round (number) + 1, 1): facto = Decimal (facto) * Decimal (n) return facto bern = [] coef = [] nmax = 250 # n = 0 bern.append ((Decimal ('1'))) # n = 1 bern.append ((- Decimal ('1') / Decimal ('2'))) for n in range (2, nmax + 2, 1): temp = Decimal ('0') for i in range (0, round (n), 1): temp = Decimal (temp) - my_factorial (Decimal (n)) * Decimal (bern[i]) / (my_factorial (Decimal (n) + Decimal ('1') - Decimal (i)) * my_factorial (Decimal (i))) bern.append ((Decimal (temp))) temp = Decimal (bern[n - 2]) * Decimal ('4') ** ((Decimal (n) - Decimal ('2')) / Decimal ('2')) \ * (Decimal ('1') - Decimal ('4') ** ((Decimal (n) - Decimal ('2')) / Decimal ('2'))) \ / my_factorial (Decimal (n) - Decimal ('2')) if temp < 0: temp = Decimal (temp) * Decimal ('-1') coef.append ((Decimal (temp))) for i in range (2, nmax, 2): print ('{:22.20e}'.format (coef[i]))