(Python)
from sympy import integer_nthroot, primorial
def oblong(n): r = integer_nthroot(n, 2)[0]; return r*(r+1) == n
def a(n):
m = psharp = primorial(n)
while not oblong(m): m += psharp
return m
print([a(n) for n in range(1, 11)]) # Michael S. Branicky, May 25 2022
(Python) # faster alternative using Python 3.8+ A344005(n) by Chai Wah Wu
from sympy import primorial
def a(n): return (m := A344005(primorial(n)))*(m+1)
print([a(n) for n in range(1, 18)]) # Michael S. Branicky, May 26 2022
(PARI) a002110(n) = prod(i=1, n, prime(i)) \\ after Washington Bomfim in A002110
a344005(n) = for(m=1, oo, if((m*(m+1))%n==0, return(m)))
a(n) = my(m=a344005(a002110(n))); m*(m+1) \\ Felix Fröhlich, May 31 2022
|