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”).

A023969
a(n) = round(sqrt(n)) - floor(sqrt(n)).
3
0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0
OFFSET
0,1
COMMENTS
First bit in fractional part of binary expansion of square root of n.
FORMULA
Runs are 0^1, 0^2 1, 0^3 1^2, 0^4 1^3, ...
a(n) = 1 iff n >= 3 and n is in the interval [k*(k+1) + 1, ..., k*(k+1) + k] for some k >= 1.
a(n) = floor(2*sqrt(n)) - 2*floor(sqrt(n)). - Mircea Merca, Jan 31 2012
a(n) = A000194(n) - A000196(n) = floor(sqrt(n) + 1/2) - floor(sqrt(n)). - Ridouane Oudra, Jun 20 2019
MAPLE
seq(floor(2*sqrt(n))-2*floor(sqrt(n)), n=0..100); # Ridouane Oudra, Jun 20 2019
MATHEMATICA
Array[ Function[ n, RealDigits[ N[ Power[ n, 1/2 ], 10 ], 2 ]// (#[ [ 1, #[ [ 2 ] ]+1 ] ])& ], 110 ]
Table[Round[Sqrt[n]]-Floor[Sqrt[n]], {n, 0, 120}] (* Harvey P. Dale, Jan 02 2018 *)
PROG
(PARI) a(n)=sqrtint(4*n)-2*sqrtint(n) \\ Charles R Greathouse IV, Jan 31 2012
(Python)
from gmpy2 import isqrt_rem
def A023969(n):
i, j = isqrt_rem(n)
return int(4*(j-i) >= 1) # Chai Wah Wu, Aug 16 2016
CROSSREFS
Sequence in context: A355453 A336356 A319988 * A060039 A319710 A345951
KEYWORD
nonn
EXTENSIONS
Revised by N. J. A. Sloane, Mar 20 2003
STATUS
approved