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!)
A316997 Number of 1's in the first n digits of the binary expansion of sqrt(n). 1
0, 1, 1, 2, 1, 2, 4, 3, 5, 2, 5, 5, 9, 7, 11, 13, 1, 7, 9, 9, 12, 9, 11, 14, 10, 2, 13, 13, 16, 12, 16, 12, 16, 19, 18, 15, 2, 21, 18, 20, 19, 25, 19, 20, 25, 26, 19, 24, 26, 3, 20, 25, 25, 31, 28, 36, 30, 33, 33, 37, 38 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,4

LINKS

Rainer Rosenthal, Table of n, a(n) for n = 0..1000

FORMULA

a(n^2) = A000120(n). - Michel Marcus, Dec 15 2018

EXAMPLE

For n = 7 we have sqrt(7) = 2.64575131... with binary expansion 10.1010010.... Of the first 7 digits there are a(7) = 3 digits equal to 1.

MAPLE

zaehle := proc(n) local e, p, c, i, z, m; Digits := n+5; e := evalf(sqrt(n)); p := [op(convert(e, binary))]; c := convert(p[1], base, 10); z := 0; m := min(n, nops(c)); for i to m do if c[-i] = 1 then z := z+1; fi; od; return z; end: seq(zaehle(n), n=0..60); # Rainer Rosenthal, Dec 14 2018

a := n -> StringTools:-CountCharacterOccurrences(convert(convert(evalf(sqrt(n), n+5), binary, n), string), "1"): seq(a(n), n=0..60); # Peter Luschny, Dec 15 2018

MATHEMATICA

a[n_] := Count[RealDigits[Sqrt[n], 2, n][[1]], 1]; Array[a, 60, 0] (* Amiram Eldar, Dec 14 2018 *)

PROG

(PARI) a(n)=my(v=concat(binary(sqrt(n)))); hammingweight(v[1..n]) \\ Hugo Pfoertner, Dec 16 2018

CROSSREFS

Cf. A004539, A004547, A004555, A004609, A004569, A004585.

Cf. A000120, A000290.

Sequence in context: A131380 A100461 A302655 * A323465 A124904 A187500

Adjacent sequences:  A316994 A316995 A316996 * A316998 A316999 A317000

KEYWORD

nonn,easy,base

AUTHOR

Rainer Rosenthal, Dec 14 2018

STATUS

approved

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 29 14:08 EDT 2022. Contains 354913 sequences. (Running on oeis4.)