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-2 of 2 results.

A143146 a(n) is the smallest positive multiple of n that has the same number of 0's as 1's in its binary representation.

Original entry on oeis.org

2, 2, 9, 12, 10, 12, 35, 56, 9, 10, 44, 12, 52, 42, 135, 240, 153, 180, 38, 180, 42, 44, 184, 216, 50, 52, 135, 56, 232, 150, 527, 992, 165, 170, 35, 180, 37, 38, 156, 240, 41, 42, 172, 44, 135, 184, 141, 240, 49, 50, 153, 52, 212, 216, 165, 56, 228, 232, 177, 180
Offset: 1

Views

Author

Leroy Quet, Jul 27 2008

Keywords

Examples

			For n = 7, checking: 7*1 = 7 = 111_2; 7*2 = 14 = 1110_2; 7*3 = 21 = 10101_2; 7*4 = 28 = 11100_2. All of these have two many 1's in binary. But 7*5 = 35 = 100011_2, which has both three 0's and three 1's. So a(7) = 35.
		

Crossrefs

Programs

  • Maple
    a:=proc(n) local b,k: b:=proc(m) convert(m,base,2) end proc: for k while add(b(k*n)[j],j=1..nops(b(k*n))) <> nops(b(k*n))-add(b(k*n)[j],j=1..nops(b(k*n))) do end do: k*n end proc: seq(a(n),n=1..60); # Emeric Deutsch, Aug 16 2008
  • Mathematica
    spm[n_]:=Module[{k=1},While[DigitCount[k*n,2,0]!=DigitCount[k*n,2,1], k++]; k*n]; Array[spm,60] (* Harvey P. Dale, Apr 25 2014 *)
  • Python
    def a(n):
        m = n
        b = bin(m)[2:]
        while len(b) != 2*b.count("1"):
            m += n
            b = bin(m)[2:]
        return m
    print([a(n) for n in range(1, 61)]) # Michael S. Branicky, May 15 2022

Formula

a(n) = n * A351599(n). - Rémy Sigrist, Jul 11 2022

Extensions

More terms from Emeric Deutsch, Aug 16 2008

A355639 a(n) is the least k > 0 such that the balanced ternary expansion of k*n contains as many negative trits as positive trits.

Original entry on oeis.org

1, 2, 1, 2, 2, 4, 1, 8, 1, 2, 2, 14, 2, 2, 4, 4, 1, 8, 1, 14, 1, 8, 7, 2, 1, 16, 1, 2, 2, 8, 2, 2, 1, 14, 4, 2, 2, 2, 7, 2, 2, 4, 4, 2, 10, 4, 1, 4, 1, 2, 8, 8, 1, 8, 1, 8, 1, 14, 4, 4, 1, 8, 1, 8, 5, 2, 7, 14, 2, 2, 1, 2, 1, 2, 1, 16, 7, 2, 1, 8, 1, 2, 2, 8
Offset: 0

Views

Author

Rémy Sigrist, Jul 11 2022

Keywords

Comments

The sequence is well defined: for n > 0, by the pigeonhole principle, there are necessarily two distinct integers i and j (say with i > j) such that 3^i == 3^j (mod n); the value 3^i - 3^j is a positive multiple of n containing exactly one positive trit and one negative trit, so a(n) <= (3^i - 3^j) / n.

Examples

			For n = 5:
- the first multiple of 5 (alongside their balanced ternary expansions) are:
      k  k*5  bter(k*5)  #1  #T
      -  ---  ---------  --  --
      1    5        1TT   1   2
      2   10        101   2   0
      3   15       1TT0   1   2
      4   20       1T1T   2   2
- negative and positive trits are first balanced for k = 4,
- so a(5) = 4.
		

Crossrefs

See A351599 for a similar sequence.

Programs

  • PARI
    a(n) = { for (k=1, oo, my (m=k*n, s=0, d); while (m, m=(m-d=[0,1,-1][1+m%3])/3; s+=d); if (s==0, return (k))) }

Formula

a(n) = 1 iff n belongs to A174658.
Showing 1-2 of 2 results.