login
a(n) = largest k such that A000961(n+1) = A000961(n) + (A000961(n) mod k), or 0 if no such k exists.
3

%I #23 Oct 18 2024 06:15:11

%S 0,0,2,3,3,6,7,7,9,10,15,15,15,21,23,25,27,30,27,33,39,39,45,45,47,57,

%T 58,61,63,69,67,77,79,77,81,93,99,99,105,105,105,117,123,126,125,125,

%U 135,129,147,145,151,159,165,165,167,177,171,189,189,195

%N a(n) = largest k such that A000961(n+1) = A000961(n) + (A000961(n) mod k), or 0 if no such k exists.

%C From the definition, a(n) = A000961(n) - A057820(n) if A000961(n) - A057820(n) > A057820(n), 0 otherwise where A000961 are the prime powers and A057820 are the gaps between prime powers.

%H Rémi Eismann, <a href="/A184830/b184830.txt">Table of n, a(n) for n = 1..9790</a>

%e For n = 1 we have A000961(1) = 1, A000961(2) = 2; for all k >= 2, 2 = 1 + (1 mod k), hence the largest k does not exist and a(1) = 0.

%e For n = 3 we have A000961(3) = 3, A000961(4) = 4; 2 is the largest k such that 4 = 3 + (3 mod k), hence a(3) = 2.

%e For n = 24 we have A000961(24) = 49, A000961(25) = 53; 45 is the largest k such that 53 = 49 + (49 mod k), hence a(24) = 45.

%p A184830 := proc(n)

%p if A000961(n) > 2*A057820(n) then

%p A000961(n)-A057820(n) ;

%p else

%p 0;

%p end if;

%p end proc:

%p seq(A184830(n),n=1..40) ; # _R. J. Mathar_, Sep 23 2016

%t nmax = 10000;

%t ppmax = 12*nmax; (* increase prime power max coef 12 in case of overflow *)

%t A000961 = Join[{1}, Select[Range[2, ppmax], PrimePowerQ]];

%t A057820 = Differences[A000961];

%t a[n_] := If[A000961[[n]] > 2*A057820[[n]], A000961[[n]] - A057820[[n]], 0];

%t Table[a[n], {n, 1, nmax}] (* _Jean-François Alcover_, Aug 06 2023 *)

%Y Cf. A000961, A057820, A184829, A184831, A117078, A117563, A001223, A118534.

%K nonn,easy

%O 1,3

%A _Rémi Eismann_, Jan 23 2011