The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A111755 Excess of n over a greedy sum of distinct squares. 1

%I #13 Oct 17 2018 04:40:44

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

%T 0,0,0,1,2,0,0,1,2,3,0,0,1,2,0,0,1,2,0,0,1,2,3,0,0,1,2,0,0,0,0,1,2,0,

%U 0,1,2,3,0,0,1,2,0,0,1,0,0,0,1,2,0,0,1,2,3,0,0,1,2,0,0,1,0,0,1,0,0,1,2,0,0

%N Excess of n over a greedy sum of distinct squares.

%C Start with the value n and subtract the largest square (not previously used) less than or equal to n to get a new value. Repeat until the value 0 is reached or the square 1 has been subtracted. The resulting value is a(n). It is not hard to prove that a(n) always lies in 0..3 inclusive.

%C All nonzero terms are one greater than the previous term. - _Iain Fox_, Oct 17 2018

%H Iain Fox, <a href="/A111755/b111755.txt">Table of n, a(n) for n = 1..10000</a>

%F a(A003995(n)) = 0. - _Iain Fox_, Oct 17 2018

%e a(24)=3, since 24 -> 24 - 16 = 8 -> 8 - 4 = 4 -> 4 - 1 = 3.

%t f[n_] := Block[{s = n, k = Floor@Sqrt@n}, While[k > 0, If[s >= k^2, s -= k^2]; k-- ]; s]; Array[f, 105] (* _Robert G. Wilson v_, Nov 22 2005 *)

%o (PARI) a(n) = my(s=sqrtint(n)); while(s > 0, if(n >= s^2, n -= s^2); s--); n \\ _Iain Fox_, Oct 17 2018

%Y Cf. A003995.

%K easy,nonn

%O 1,3

%A _John W. Layman_, Nov 21 2005

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 4 17:06 EDT 2024. Contains 373101 sequences. (Running on oeis4.)