Increasing recursion fails with: Process finished with exit code -1073741571 (0xC00000FD)

import sys sys.setrecursionlimit(1000000000) def F(n): if n == 1: return 1 if n > 1: return n * F(n – 1) print(F(2023)/F(2020)) When the recursion is increased with setrecursionlimit, the following error is returned. Process finished with exit code -1073741571 (0xC00000FD) But without increasing the recursion, this code does not work. How can I fix… Read More Increasing recursion fails with: Process finished with exit code -1073741571 (0xC00000FD)

How to perform binomial-coefficient and factorial calculation with more precision?

I was comparing the result of my following python calculation with Mathematica: https://www.wolframalpha.com/input?i=sum+%28500+choose+r+%29%28-1%29%5Er+%2F%28r%21%29+%2C+r%3D0+to+500 import numpy as np from decimal import * import scipy.special from scipy.special import factorial getcontext().prec = 30 i = 500 sum(np.array([scipy.special.comb(Decimal(i), (r), exact=True)*pow(-1, r)/Decimal(factorial(r, exact=False)) for r in range(i+1)])) Both calculations are giving almost same value until i = 400 but failing… Read More How to perform binomial-coefficient and factorial calculation with more precision?