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-10 of 102 results. Next

A071925 Digitally balanced numbers: binary numbers which have the same number of 0's as 1's; decimal representation: A031443.

Original entry on oeis.org

10, 1001, 1010, 1100, 100011, 100101, 100110, 101001, 101010, 101100, 110001, 110010, 110100, 111000, 10000111, 10001011, 10001101, 10001110, 10010011, 10010101, 10010110, 10011001, 10011010, 10011100, 10100011
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 14 2002

Keywords

Crossrefs

Programs

  • Mathematica
    Select[FromDigits/@Tuples[{0,1},8],DigitCount[#,10,1]==DigitCount[#,10,0]&] (* Harvey P. Dale, Sep 08 2024 *)
  • Python
    from itertools import islice, count
    from sympy.utilities.iterables import multiset_permutations
    def A071925gen(): # generator of terms
        for n in count(1):
            yield from (int('1'+''.join(p)) for p in multiset_permutations('0'*n+'1'*(n-1)))
    A071925_list = list(islice(A071925gen(),30)) # Chai Wah Wu, Dec 06 2021

Formula

a(n) = A007088(A031443(n)).

A337238 Number k such that k and k+1 are both digitally balanced numbers in base 2 (A031443).

Original entry on oeis.org

9, 37, 41, 49, 141, 149, 153, 165, 169, 177, 197, 201, 209, 225, 541, 557, 565, 569, 589, 597, 601, 613, 617, 625, 653, 661, 665, 677, 681, 689, 709, 713, 721, 737, 781, 789, 793, 805, 809, 817, 837, 841, 849, 865, 901, 905, 913, 929, 961, 2109, 2141, 2157, 2165
Offset: 1

Views

Author

Amiram Eldar, Nov 21 2020

Keywords

Comments

All the terms are of the form 4*k + 1, where k is a digitally balanced number in base 2. Therefore, there are no 3 consecutive numbers that are digitally balanced in base 2.
The number of terms below 2^k is A079309(floor(k/2)-1) for k > 3.

Examples

			9 is a term since the binary representation of 9 is 1001, which contains 2 0's and 2 1's, and the binary representation of 9 + 1 = 10 is 1010, which also contains 2 0's and 2 1's.
		

Crossrefs

A206374 \ {2} is a subsequence.

Programs

  • Mathematica
    digBalQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ@(m = Length@d) && Count[d, 1] == m/2]; Select[Range[2000], digBalQ[#] && digBalQ[# + 1] &]

Formula

a(n) = 4*A031443(n) + 1.

A345397 a(n) is the least number k such that {k, k^2, ..., k^n} are all digitally balanced numbers in base 2 (A031443), or 0 if no such k exists.

Original entry on oeis.org

2, 212, 3274, 15113, 236417, 15975465, 991017155, 4006725713, 4079348720699
Offset: 1

Views

Author

Amiram Eldar, Jun 17 2021

Keywords

Comments

Conjecture: all a(n) > 0. - Alex Ratushnyak, Apr 26 2022

Examples

			a(1) = 2 since 2 is digitally balanced: its binary representation, 10, has the same number of 0's and 1's.
a(2) = 212 since both 212 and 212^2 are digitally balanced: the binary representation of 212, 11010100, has 4 0's and 4 1's, and the binary representation of 212^2, 1010111110010000, has 8 0's and 8 1's.
		

Crossrefs

Programs

  • Mathematica
    balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; f[k_] := Module[{e = 0, r = k}, While[balQ[r], r *= k; e++]; e]; mx = 5; s = Table[0, {mx}]; c = 0; n = 1; While[c < mx, k = f[n]; Do[If[s[[i]] == 0, s[[i]] = n; c++], {i, 1, k}]; n++]; s
  • Python
    from itertools import count, islice
    from sympy.utilities.iterables import multiset_permutations
    def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
    def A031443gen(): yield from (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))
    def a(n):
        for k in A031443gen():
            if all(isbalanced(k**i) for i in range(2, n+1)):
                return k
    print([a(n) for n in range(1, 6)]) # Michael S. Branicky, Apr 26 2022

Extensions

a(9) from Bert Dobbelaere, Jun 18 2021
Name edited by Alex Ratushnyak, Apr 26 2022

A145057 First differences of A031443.

Original entry on oeis.org

2, 7, 1, 2, 23, 2, 1, 3, 1, 2, 5, 1, 2, 4, 79, 4, 2, 1, 5, 2, 1, 3, 1, 2, 7, 2, 1, 3, 1, 2, 5, 1, 2, 4, 11, 2, 1, 3, 1, 2, 5, 1, 2, 4, 9, 1, 2, 4, 8, 287, 8, 4, 2, 1, 9, 4, 2, 1, 5, 2, 1, 3, 1, 2, 11, 4, 2, 1, 5, 2, 1, 3, 1, 2, 7, 2, 1, 3, 1, 2, 5, 1, 2, 4, 15, 4, 2, 1, 5, 2, 1, 3, 1, 2, 7, 2, 1, 3, 1, 2, 5, 1
Offset: 1

Views

Author

Reikku Kulon, Sep 30 2008

Keywords

Comments

a(n) equals the differences between k where A145037(k) equals zero. - Reikku Kulon, Oct 02 2008

Examples

			a(3) = A031443(3) - A031443(3-1) = 10 - 9 = 1. - _David A. Corneth_, Apr 26 2022
		

Crossrefs

Programs

  • Mathematica
    Differences[Select[Range[0, 1000], SameQ@@DigitCount[#, 2] &]] (* Paolo Xausa, Nov 16 2024 *)

A353139 Digitally balanced numbers (A031443) whose squares are also digitally balanced.

Original entry on oeis.org

212, 781, 794, 806, 817, 838, 841, 844, 865, 2962, 3101, 3130, 3171, 3178, 3185, 3213, 3219, 3226, 3269, 3274, 3335, 3353, 3354, 3356, 3370, 3378, 3490, 3496, 3521, 3528, 3595, 3597, 3606, 3610, 3626, 3651, 3672, 3718, 3777, 11797, 11798, 11850, 11938, 12049
Offset: 1

Views

Author

Alex Ratushnyak, Apr 26 2022

Keywords

Comments

Numbers x such that both x and x^2 are terms of A031443, that is, have the same number of 0's as 1's in their binary representations.

Crossrefs

Programs

  • Mathematica
    balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; Select[Range[12000], balQ[#] && balQ[#^2] &] (* Amiram Eldar, Apr 26 2022 *)
  • Python
    from itertools import count, islice
    from sympy.utilities.iterables import multiset_permutations
    def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
    def A031443gen(): yield from (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))
    def agen():
        for k in A031443gen():
            if isbalanced(k**2):
                yield k
    print(list(islice(agen(), 40))) # Michael S. Branicky, Apr 26 2022

A337258 Primes p such that p and the prime next to p are both digitally balanced numbers in base 2 (A031443).

Original entry on oeis.org

37, 139, 557, 563, 613, 647, 653, 659, 2389, 2467, 2699, 2851, 8311, 8423, 8627, 8677, 8681, 8807, 8819, 9011, 9043, 9049, 9157, 9319, 9323, 9419, 9613, 9803, 9811, 9817, 9829, 9923, 10331, 10343, 10453, 10597, 11279, 11317, 11353, 11399, 11587, 11783, 11789
Offset: 1

Views

Author

Amiram Eldar, Nov 21 2020

Keywords

Comments

Prime p such that p and the prime next to p are both terms of A066196.

Examples

			37 is a term since it is a prime number, and both 37 and the next prime, 41, are digitally balanced in base 2: the binary representation of 37 is 100101, the binary representation of 41 is 101001, and both contain 3 0's and 3 1's.
		

Crossrefs

Programs

  • Mathematica
    digBalQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ@(m = Length@d) && Count[d, 1] == m/2]; p = Select[Range[3*10^4], PrimeQ]; p[[Position[Partition[digBalQ /@ p, 2, 1], {True, True}] // Flatten]]

A345395 Composite numbers whose divisors that are larger than 1 are all digitally balanced numbers in base 2 (A031443).

Original entry on oeis.org

132061, 138421, 151427, 532393, 545269, 546407, 557983, 559609, 568801, 570709, 573193, 579013, 590687, 595853, 599707, 604873, 610777, 624553, 630293, 635213, 2102767, 2105063, 2109383, 2111339, 2123677, 2128187, 2129081, 2129609, 2143961, 2149753, 2151131, 2151661
Offset: 1

Views

Author

Amiram Eldar, Jun 17 2021

Keywords

Comments

The prime numbers with this property are the digitally balanced primes (A066196).
All the terms are odd, since if k is an even digitally balanced number then its divisor k/2 is not digitally balanced (since it has one fewer 0 in its binary expansion).
Apparently most of the terms are semiprimes (A001358) with 4 divisors.
Terms with 3 divisors, i.e., squares of primes: 145178401 = 12049^2, 155575729 = 12473^2, ...
The least term with more than 4 divisors is 8897396239 = 163 * 929 * 58757, with 8 divisors.
The least term with 6 divisors is 8923691369 = 41 * 14753^2.

Examples

			132061 is a term since its divisors that are larger than 1 are {41, 3221, 132061}, and their binary representations are {101001, 110010010101, 100000001111011101}. Each one has an equal number of 0's and 1's.
		

Crossrefs

Subsequence of A031443.
Cf. A066196.

Programs

  • Mathematica
    balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length @ d) && Count[d, 1] == m/2]; Select[Range[9,10^6,2], CompositeQ[#] && AllTrue[Rest@Divisors[#], balQ] &]
  • PARI
    isbal(k) = exponent(k) + 1 == 2 * hammingweight(k);
    isok(k) = if(k == 1 || isprime(k), 0, fordiv(k, d, if(d > 1 && !isbal(d), return(0))); 1); \\ Amiram Eldar, Jul 03 2025

A351599 a(n) is the smallest integer m > 0 such that m*n is a digitally balanced number (A031443).

Original entry on oeis.org

2, 1, 3, 3, 2, 2, 5, 7, 1, 1, 4, 1, 4, 3, 9, 15, 9, 10, 2, 9, 2, 2, 8, 9, 2, 2, 5, 2, 8, 5, 17, 31, 5, 5, 1, 5, 1, 1, 4, 6, 1, 1, 4, 1, 3, 4, 3, 5, 1, 1, 3, 1, 4, 4, 3, 1, 4, 4, 3, 3, 13, 9, 33, 63, 3, 3, 3, 3, 10, 3, 2, 3, 11, 9, 2, 3, 2, 2, 8, 3, 10, 9, 2
Offset: 1

Views

Author

Alex Ratushnyak, May 02 2022

Keywords

Crossrefs

Programs

  • Mathematica
    balQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ@(m = Length@d) && Count[d, 1] == m/2]; a[n_] := Module[{k = 1}, While[!balQ[k*n], k++]; k]; Array[a, 100] (* Amiram Eldar, May 02 2022 *)
  • PARI
    is(n) = hammingweight(n)==hammingweight(bitneg(n, #binary(n))); \\ A031443
    a(n) = my(m=1); while (!is(m*n), m++); m; \\ Michel Marcus, May 02 2022

Formula

a(n) = A143146(n) / n. - Rémy Sigrist, Jul 11 2022

A357035 a(n) is the smallest number that has exactly n divisors that are digitally balanced numbers (A031443).

Original entry on oeis.org

1, 2, 10, 36, 150, 180, 420, 840, 900, 3420, 2520, 5040, 6300, 7560, 12600, 15120, 18900, 42840, 32760, 37800, 95760, 105840, 69300, 124740, 163800, 138600, 166320, 327600, 249480, 207900, 491400, 622440, 498960, 706860, 415800, 963900, 1496880, 1164240, 1081080
Offset: 0

Views

Author

Marius A. Burtea, Sep 20 2022

Keywords

Examples

			1 has no divisors in A031443, so a(0) = 1;
2 has divisors 1 = 1_2, 2 = 10_2 and 2 = A031443(1), so a(1) = 2.
10 has divisors 2 = 10_2 and 10 = 1010_2 in A031443, so a(2) = 10.
		

Crossrefs

Cf. A031443.

Programs

  • Magma
    bal:=func; a:=[]; for n in [0..38] do k:=1; while #[d:d in Divisors(k)|bal(d)] ne n  do k:=k+1; end while; Append(~a,k); end for; a;
  • Maple
    N:= 20: # for terms before the first term >= 2^(N+1)
    W:= Vector(2^(N+1),datatype=integer[4]):
    for d from 2 to N by 2 do
    for t from 2^(d-1) to 2^d-1 do
      if convert(convert(t,base,2),`+`) = d/2 then
        J:= [seq(i,i=t..2^(N+1), t)];
        W[J]:= W[J] +~ 1;
    fi od od:
    M:= max(W);
    V:= Array(0..M); count:= 0:
    for i from 1 to 2^(N+1) do
      if V[W[i]] = 0 then V[W[i]]:= i; count:= count+1 fi
    od:
    L:= convert(V,list):
    if not member(0,L,'m') then m:= M+2 fi:
    L[1..m-1]; # Robert Israel, Sep 27 2023
  • Mathematica
    digBalQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ @ (m = Length[d]) && Count[d, 1] == m/2]; f[n_] := DivisorSum[n, 1 &, digBalQ[#] &]; seq[len_, nmax_] := Module[{s = Table[0, {len}], c = 0, n = 1, i}, While[c < len && n < nmax, i = f[n] + 1; If[i <= len && s[[i]] == 0, c++; s[[i]] = n]; n++]; s]; seq[40, 10^7] (* Amiram Eldar, Sep 26 2022 *)

Extensions

Corrected by Robert Israel, Sep 27 2023

A358857 Least integer k in A031443 such that k*n is also in A031443, or -1 if there is no such k.

Original entry on oeis.org

2, -1, 49, -1, 2, 2, 535, -1, 3843, 899, 49, 197, 12, 52, 9, -1, 9, 10, 2, 9, 2, 2, 35, 9, 2, 2, 147, 2, 2141, 2095, 32991, -1, 258055, 63495, 3849, 15367, 961, 906, 226, 3603, 56, 201, 49, 197, 49, 49, 50, 789, 56, 56, 42, 209, 50, 42, 44, 41, 10, 12, 10, 41
Offset: 1

Views

Author

Jeffrey Shallit, Dec 03 2022

Keywords

Comments

It's clear that a(2^i)=-1 if i>0, because 2^i*n always has more 0's than n does. I do not know if every number other than a power
of 2 has such a k. Local maxima seem to be near odd powers of 2. It is not hard to show that a(2^n +- 1)!=-1 for n>=1.

Examples

			For n = 3 both 49 = [110001] and 49*3 = [10010011] have the same number of 0's as 1's, and this is the least such.
		

Crossrefs

Programs

  • PARI
    See Links section.
  • Python
    from itertools import count
    from sympy.utilities.iterables import multiset_permutations
    def isbalanced(n): b = bin(n)[2:]; return b.count("0") == b.count("1")
    def A031443gen(): yield from (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1)))
    def a(n):
        if n > 1 and bin(n)[2:].strip("0") == "1": return -1
        return next(k for k in A031443gen() if isbalanced(k*n))
    print([a(n) for n in range(1, 61)]) # Michael S. Branicky, Dec 03 2022
    

Formula

a(n) = A358858(n)/n unless a(n) = -1. - Pontus von Brömssen, Dec 03 2022
Showing 1-10 of 102 results. Next