login
Number of ways to express n as k+l*m, with k, l, m all in the range [0..n].
4

%I #35 May 12 2024 11:35:02

%S 1,4,8,12,17,21,27,31,37,42,48,52,60,64,70,76,83,87,95,99,107,113,119,

%T 123,133,138,144,150,158,162,172,176,184,190,196,202,213,217,223,229,

%U 239,243,253,257,265,273,279,283,295,300,308,314,322,326,336,342,352

%N Number of ways to express n as k+l*m, with k, l, m all in the range [0..n].

%C Number of ordered triples [k,l,m] with n = k+l*m and k, l, m all in the range [0..n].

%C From _R. J. Mathar_, Jun 30 2013: (Start)

%C A010766 is the following array A read by antidiagonals:

%C 1, 1, 1, 1, 1, 1, ...

%C 2, 1, 1, 1, 1, 1, ...

%C 3, 2, 1, 1, 1, 1, ...

%C 4, 2, 2, 1, 1, 1, ...

%C 5, 3, 2, 2, 1, 1, ...

%C 6, 3, 2, 2, 2, 1, ...

%C and apparently a(n) is the hook sum Sum_{k=0..n} A(n,k) + Sum_{r=0..n-1} A(r,n). (End)

%H R. J. Mathar, <a href="/A106633/b106633.txt">Table of n, a(n) for n = 0..1000</a>

%F From _Ridouane Oudra_, Apr 22 2024: (Start)

%F a(n) = 2*n + 1 + Sum_{k=1..n} floor(n/k);

%F a(n) = 2*n + 1 + Sum_{k=1..n} tau(k);

%F a(n) = A005408(n) + A006218(n). (End)

%e 0+1*2 = 0+2*1 = 1+1*1 = 2+0*0 = 2+0*1 = 2+0*2 = 2+1*0 = 2+2*0 = 2, so a(2)=8.

%e a(3)=12: 3+0*0, 3+0*m (6), 2+1*1, 1+2*1 (2), 0+3*1 (2).

%p A106633 := proc(n)

%p local a, k, l, m ;

%p a := 0 ;

%p for k from 0 to n do

%p for l from 0 to n do

%p if l = 0 then

%p if k = n then

%p a := a+n+1 ;

%p end if;

%p else

%p m := (n-k)/l ;

%p if type(m,'integer') then

%p a := a+1 ;

%p end if;

%p end if;

%p end do:

%p end do:

%p a ;

%p end proc: # _R. J. Mathar_, Oct 17 2012

%t A106633[n_] := Module[{a, m}, a = 0; Do[If[l == 0, If[k == n, a = a + n + 1], m = (n - k)/l; If[IntegerQ[m], a = a + 1]], {k, 0, n}, {l, 0, n}]; a];

%t Table[A106633[n], {n, 0, 56}] (* _Jean-François Alcover_, Jun 10 2023, after _R. J. Mathar_ *)

%o (PARI) list(n)={

%o my(v=vector(n),t);

%o for(i=2,n,for(j=1,min(n\i,i-1),v[i*j]+=2));

%o for(i=1,sqrtint(n),v[i^2]++);

%o concat(1,vector(n,k,2*k+1+t+=v[k]))

%o }; \\ _Charles R Greathouse IV_, Oct 17 2012

%Y Cf. A006218, A106634, A106846, A106847.

%Y Cf. A005408, A006218.

%K nonn,easy

%O 0,2

%A _Ralf Stephan_, May 06 2005

%E Definition clarified by _N. J. A. Sloane_, Jul 07 2012