cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-8 of 8 results.

A159918 Number of ones in binary representation of n^2.

Original entry on oeis.org

0, 1, 1, 2, 1, 3, 2, 3, 1, 3, 3, 5, 2, 4, 3, 4, 1, 3, 3, 5, 3, 6, 5, 3, 2, 5, 4, 6, 3, 5, 4, 5, 1, 3, 3, 5, 3, 6, 5, 7, 3, 5, 6, 7, 5, 8, 3, 4, 2, 5, 5, 5, 4, 8, 6, 7, 3, 6, 5, 7, 4, 6, 5, 6, 1, 3, 3, 5, 3, 6, 5, 7, 3, 6, 6, 9, 5, 7, 7, 5, 3, 6, 5, 8, 6, 7, 7, 7, 5, 9, 8, 5, 3, 6, 4, 5, 2, 5, 5, 6, 5, 9, 5, 7, 4
Offset: 0

Views

Author

Reinhard Zumkeller, Apr 25 2009

Keywords

Comments

The binary weight (A000120) of n^2.
a(n) = 0 iff n = 0. a(n) = 1 iff n = 2^k for some k >= 0. a(n) = 2 iff n = 3*2^k for some k >= 0. Szalay proves that a(n) = 3 iff n = 7*2^k, 23*2^k, or 2^a + 2^b for k >= 0 and a > b >= 0. It seems that a(n) = 4 iff n = 13*2^k, 15*2^k, 47*2^k, or 111*2^k but this has not been proven! Any other n with a(n) = 4 are greater than 10^50, and there are finitely many odd solutions. - Charles R Greathouse IV, Jan 20 2022

References

  • L. Szalay, The equations 2^n ± 2^m ± 2^l = z^2, Indagationes Mathematicae (N.S.) 13, no. 1 (2002), pp. 131-142.

Crossrefs

Programs

Formula

a(n) = A000120(A000290(n)); a(A077436(n)) = A000120(A077436(n)).
Lindström shows that lim sup wt(m^2)/log_2 m = 2. - N. J. A. Sloane, Oct 11 2013
a(n) = [x^(n^2)] (1/(1 - x))*Sum_{k>=0} x^(2^k)/(1 + x^(2^k)). - Ilya Gutkovskiy, Mar 27 2018

A089998 Smallest square with Hamming weight n (i.e., with exactly n 1's when written in binary).

Original entry on oeis.org

0, 1, 9, 25, 169, 121, 441, 1521, 2025, 5625, 24025, 47089, 109561, 32761, 393129, 851929, 1540081, 6275025, 15327225, 27258841, 41925625, 127893481, 243204025, 385611769, 998244025, 1979449081, 4823441401, 12870221809, 34324602361
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Comments

A000120(a(n)) = n.

Crossrefs

Programs

  • Mathematica
    a = Table[0, {30}]; Do[c = Count[IntegerDigits[n^2, 2], 1]; If[ a[[c + 1]] == 0, a[[c + 1]] = n^2; Print[c, " = ", n^2]], {n, 1, 360000}] (* Robert G. Wilson v, Dec 03 2003 *)
    Join[{0},With[{s=DigitCount[Range[400000]^2,2,1]},Flatten[Table[ Position[ s,?(#==n&),1,1],{n,30}]]]^2] (* _Harvey P. Dale, Mar 03 2013 *)

Formula

a(n) = A231897(n)^2. - Hugo Pfoertner, Dec 27 2022

Extensions

More terms from Robert G. Wilson v, Dec 03 2003
Offset corrected by Donovan Johnson, May 01 2012

A230097 Indices of records in A159918.

Original entry on oeis.org

0, 1, 3, 5, 11, 21, 39, 45, 75, 155, 181, 627, 923, 1241, 2505, 3915, 5221, 6475, 11309, 15595, 19637, 31595, 44491, 69451, 113447, 185269, 244661, 357081, 453677, 908091, 980853, 2960011, 2965685, 5931189, 11862197, 20437147, 22193965, 43586515, 57804981, 157355851
Offset: 1

Views

Author

N. J. A. Sloane, Oct 11 2013

Keywords

Comments

The records themselves are not so interesting: 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 19, 20, ... (A357304).
Lindström mentions that the record value 34 in A159918 is first reached at n = 980853.

Crossrefs

Programs

  • Haskell
    a230097 n = a230097_list !! (n-1)
    a230097_list = 0 : f 0 0 where
       f i m = if v > m then i : f (i + 1) v else f (i + 1) m
               where v = a159918 i
    -- Reinhard Zumkeller, Oct 12 2013
    (Python 3.10+)
    from itertools import count, islice
    def A230097_gen(): # generator of terms
        c = -1
        for n in count(0):
            if (m := (n**2).bit_count())>c:
                yield n
                c = m
    A230097_list = list(islice(A230097_gen(),20)) # Chai Wah Wu, Oct 01 2022

Formula

Lindström shows that lim sup wt(m^2)/log_2 m = 2.

Extensions

a(19)-a(40) from Reinhard Zumkeller, Oct 12 2013

A231898 a(n) = smallest k with property that for all m >= k, there is a square N^2 whose binary expansion contains exactly n 1's and m 0's; or -1 if no such k exists.

Original entry on oeis.org

-1, -1, 2, -1, 4, 3, 4, 3, 4, 5, 5, 5, 6, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
Offset: 1

Views

Author

N. J. A. Sloane, Nov 19 2013

Keywords

Comments

a(n) = -1 for n = 1, 2 and 4, because all squares with exactly 1, 2 or 4 1's in their binary expansion must contain an even number of 0's.
Conjecture: Apart from n=1, 2 and 4, no other a(n) is -1.
See A214560 for a related conjecture.

Examples

			Here is a table whose columns give:
N, N^2, number of bits in N^2, number of 1's in N^2, number of 0's in N^2:
0 0 1 0 1
1 1 1 1 0
2 4 3 1 2
3 9 4 2 2
4 16 5 1 4
5 25 5 3 2
6 36 6 2 4
7 49 6 3 3
8 64 7 1 6
9 81 7 3 4
10 100 7 3 4
11 121 7 5 2
12 144 8 2 6
13 169 8 4 4
14 196 8 3 5
15 225 8 4 4
16 256 9 1 8
17 289 9 3 6
18 324 9 3 6
19 361 9 5 4
...
a(n) is defined by the property that for all m >= a(n), the table contains a row ending n m. For example, there are rows ending 3 2, 3 3, 3 4, 3 5, ..., but not 3 1, so a(3) = 2.
a(5)=4: for t>=0, (11*2^t)^2 contains 5 1's and 2t+2 0's and (25*2^t)^2 contains 5 1's and 2t+5 0's, so for m >= 4 there is a number N such that N^2 contains 5 1's and m 0's. Also 4 is the smallest number with this property, so a(5) = 4.
		

Crossrefs

Extensions

Missing word in definition supplied by Jon Perry, Nov 20 2013.

A351149 a(n) is the least exponent k such that the Hamming weight of n^(k+1) is not greater than the Hamming weight of n^k.

Original entry on oeis.org

1, 1, 1, 1, 3, 1, 1, 1, 3, 3, 5, 1, 7, 1, 1, 1, 3, 3, 4, 3, 2, 5, 1, 1, 4, 7, 5, 1, 5, 1, 1, 1, 3, 3, 7, 3, 4, 4, 3, 3, 5, 2, 5, 5, 3, 1, 1, 1, 5, 4, 7, 7, 2, 5, 3, 1, 3, 5, 2, 1, 3, 1, 1, 1, 3, 3, 4, 3, 5, 7, 3, 3, 3, 4, 3, 4, 3, 3, 1, 3, 5, 5, 3, 2, 3, 5, 11
Offset: 1

Views

Author

Hugo Pfoertner, Feb 07 2022

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{k = 1}, While[DigitCount[n^k, 2, 1] < DigitCount[n^(k + 1), 2, 1], k++]; k]; Array[a, 100] (* Amiram Eldar, Feb 07 2022 *)
  • PARI
    for(n=1,87, for(k=1,oo, my(hw1=hammingweight(n^k), hw2=hammingweight(n^(k+1))); if(hw2<=hw1, print1(k,", "); break)))
    
  • Python
    def A351149(n):
        k = 1
        while bin(n**k)[2:].count("1") < bin(n**(k+1))[2:].count("1"): k += 1
        return(k)
    print([A351149(n) for n in range(1, 88)]) # Karl-Heinz Hofmann, Feb 07 2022

A358702 a(n) is the least k > 0 such that the sum of the decimal digits of k^2 is n, or 0 if no such k exists.

Original entry on oeis.org

1, 0, 0, 2, 0, 0, 4, 0, 3, 8, 0, 0, 7, 0, 0, 13, 0, 24, 17, 0, 0, 43, 0, 0, 67, 0, 63, 134, 0, 0, 83, 0, 0, 167, 0, 264, 314, 0, 0, 313, 0, 0, 707, 0, 1374, 836, 0, 0, 1667, 0, 0, 2236, 0, 3114, 4472, 0, 0, 6833, 0, 0, 8167, 0, 8937, 16667, 0, 0, 21886, 0, 0, 29614
Offset: 1

Views

Author

Hugo Pfoertner, Dec 04 2022

Keywords

Crossrefs

The nonzero terms are A067179.
Cf. A056991, A231897 (similar for binary weight).

A359091 a(n) is the index of the smallest n-gonal number with binary weight n.

Original entry on oeis.org

6, 13, 9, 10, 24, 58, 34, 55, 67, 151, 134, 187, 201, 691, 350, 623, 1082, 1870, 2302, 3171, 5017, 13863, 13230, 6663, 24357, 50397, 35604, 60347, 63810, 107019, 181517, 365595, 624858, 1345485, 1002585, 1969415, 1191179, 7651731, 4592173, 7279863, 7403686, 17923182
Offset: 3

Views

Author

Ilya Gutkovskiy, Dec 16 2022

Keywords

Crossrefs

Programs

  • Mathematica
    p[n_, k_] := (n - 2)*k*(k - 1)/2 + k; a[n_] := Module[{k = 1}, While[DigitCount[p[n, k], 2, 1] != n, k++]; k]; Array[a, 30, 3] (* Amiram Eldar, Dec 17 2022 *)

A386242 a(n) is the least perfect power A001597 with binary weight n.

Original entry on oeis.org

1, 9, 25, 27, 121, 125, 1521, 2025, 5625, 24025, 42875, 59319, 32761, 393129, 851929, 1540081, 6275025, 15327225, 27258841, 41925625, 127893481, 243204025, 385611769, 268336125, 1979449081, 4823441401, 12870221809, 25698491351, 51354402813, 127506840561, 205822820329
Offset: 1

Views

Author

Hugo Pfoertner, Jul 23 2025

Keywords

Crossrefs

Programs

  • Mathematica
    upto = 10^11; L = Table[2 upto, {2 + Log2@ upto}]; Do[n = 1; While[(v = n^k) <= upto, nb = Plus @@ IntegerDigits[v, 2]; If[L[[nb]] > v, L[[nb]] = v]; n++], {k, 2, Log2[upto]}]; Take[L, Position[L, 2 upto][[1, 1]] - 1] (* Giovanni Resta, Jul 23 2025 *)

Extensions

a(27)-a(31) from Giovanni Resta, Jul 23 2025
Showing 1-8 of 8 results.