OFFSET
0,1
COMMENTS
First bit in fractional part of binary expansion of square root of n.
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
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
KEYWORD
nonn
AUTHOR
EXTENSIONS
Revised by N. J. A. Sloane, Mar 20 2003
STATUS
approved