editing
approved
editing
approved
More terms from James Rayman, Jan 18 2021
reviewed
editing
proposed
reviewed
editing
proposed
James Rayman, <a href="/A340727/b340727.txt">Table of n, a(n) for n = 2..400</a>
More terms from James Rayman, Jan 18 2021
approved
editing
reviewed
approved
proposed
reviewed
editing
proposed
(Python)
from heapq import *
import math
def a(n):
prev, visited, v = 0, set(), list(range(2, n+2))
pq = [(math.factorial(n+1), v)]
while True:
prod, v = heappop(pq)
if tuple(v) in visited: continue
visited.add(tuple(v))
if prev != prod: prev = prod
else: return prod
for i in range(n):
if i == n-1 or v[i] + 1 < v[i+1]:
u = v[:]
u[i] += 1
heappush(pq, (prod // v[i] * u[i], u))
proposed
editing
editing
proposed