login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Number of triangular numbers needed to represent n with greedy algorithm.
13

%I #16 Mar 10 2019 08:35:50

%S 0,1,2,1,2,3,1,2,3,2,1,2,3,2,3,1,2,3,2,3,4,1,2,3,2,3,4,2,1,2,3,2,3,4,

%T 2,3,1,2,3,2,3,4,2,3,4,1,2,3,2,3,4,2,3,4,3,1,2,3,2,3,4,2,3,4,3,2,1,2,

%U 3,2,3,4,2,3,4,3,2,3,1,2,3,2,3,4,2,3,4,3,2,3,4,1,2,3,2,3,4,2,3,4,3,2,3,4,3

%N Number of triangular numbers needed to represent n with greedy algorithm.

%C a(n) = sum of digits of A000462(n). - _Reinhard Zumkeller_, Mar 27 2011

%C The length of (number of moves in) Simon Norton's game in A006019 starting with an initial heap of n if both players always take, never put. - _R. J. Mathar_, May 13 2016

%H Reinhard Zumkeller, <a href="/A057945/b057945.txt">Table of n, a(n) for n = 0..10000</a>

%F a(0)=0, otherwise a(n)=a(A002262(n))+1.

%e a(35)=3 since 35=28+6+1

%p A057945 := proc(n)

%p local a,x;

%p a := 0 ;

%p x := n ;

%p while x > 0 do

%p x := x-A057944(x) ;

%p a := a+1 ;

%p end do:

%p a ;

%p end proc: # _R. J. Mathar_, May 13 2016

%t A057944[n_] := With[{k = Floor[Sqrt[8n+1]]}, Floor[(k-1)/2]* Floor[(k+1)/2]/2];

%t a[n_] := Module[{k = 0, x = n}, While[x>0, x = x - A057944[x]; k++]; k];

%t Table[a[n], {n, 0, 104}] (* _Jean-François Alcover_, Mar 10 2019, after _R. J. Mathar_ *)

%o (Haskell)

%o a057945 n = g n $ reverse $ takeWhile (<= n) $ tail a000217_list where

%o g 0 _ = 0

%o g x (t:ts) = g r ts + a where (a,r) = divMod x t

%o -- _Reinhard Zumkeller_, Mar 27 2011

%Y Cf. A000217, A002262, A056944, A057944. See A006893 for records.

%K nonn

%O 0,3

%A _Henry Bottomley_, Oct 05 2000