login
a(1) = 1, a(2) = 4; for n > 2, a(n) = k*a(n-1) + 1 where k is smallest number > 1 such that k*a(n-1) + 1 is a multiple of n.
2

%I #9 May 04 2024 23:43:37

%S 1,4,9,28,85,426,3409,23864,167049,1837540,18375401,128627808,

%T 1157650273,10418852458,83350819665,1250262294976,22504721309569,

%U 382580262262674,4973543409414763,64656064322391920

%N a(1) = 1, a(2) = 4; for n > 2, a(n) = k*a(n-1) + 1 where k is smallest number > 1 such that k*a(n-1) + 1 is a multiple of n.

%C There is no solution to k * 64656064322391920 + 1 = 0 (mod 21). - _Sean A. Irvine_, May 04 2024

%e a(6) = 426, a(7) = 3409 since 3409 = 8*426 + 1 is a multiple of 7.

%t a[1] = 1; a[n_] := a[n] = Module[{k}, If[ Intersection[ Transpose[ FactorInteger[a[n - 1]]] [[1]], Transpose[ FactorInteger[n]] [[1]]] == {}, k = 2; While[ !IntegerQ[(k*a[n - 1] + 1)/n], k++ ]; Return[ k*a[n - 1] + 1], k = 1; While[ !IntegerQ[(k*a[n - 2] + 1)/n], k++ ]; Return[ k*a[n - 2] + 1]]]; Table[ a[n], {n, 1, 23}]

%K nonn,fini,full

%O 1,2

%A _Amarnath Murthy_, Mar 23 2002

%E More terms from _Sascha Kurz_, Mar 23 2002

%E Edited, corrected and extended by _Robert G. Wilson v_, Apr 12 2002

%E Incorrect a(21) removed by _Sean A. Irvine_, May 04 2024