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.

A182209 a(n) is the least m >= n, such that the Hamming distance D(n,m) = 3.

Original entry on oeis.org

7, 6, 5, 4, 9, 8, 8, 9, 15, 14, 13, 12, 16, 17, 18, 19, 23, 22, 21, 20, 25, 24, 24, 25, 31, 30, 29, 28, 36, 37, 38, 39, 39, 38, 37, 36, 41, 40, 40, 41, 47, 46, 45, 44, 48, 49, 50, 51, 55, 54, 53, 52, 57, 56, 56, 57, 63, 62, 61, 60, 76, 77, 78, 79, 71, 70, 69
Offset: 0

Views

Author

Vladimir Shevelev, Apr 18 2012

Keywords

Comments

a(n) = n<+>3 (see comment in A206853).

Crossrefs

Cf. A086799 ((n-1)<+>1), A182187 (n<+>2), A182336 (n<+>4).
Cf. A209554 (primes which are not terms nor n<+>2 terms).

Programs

  • Maple
    HD:= (i, j)-> add(h, h=Bits[Split](Bits[Xor](i, j))):
    a:= proc(n) local c;
          for c from n do if HD(n, c)=3 then return c fi od
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Apr 18 2012
  • PARI
    a(n) = bitxor(n, if(bitand(n,14)==4, 13, 7<>2+1,2))); \\ Kevin Ryde, Jul 10 2021
  • Python
    def d(n, m): return bin(n^m).count('1')
    def a(n):
        m = n+1
        while d(n, m) != 3: m += 1
        return m
    print([a(n) for n in range(67)]) # Michael S. Branicky, Jul 06 2021
    

Formula

If n==i mod 8, then a(n) = n-2*i+7, i=0,1,2,3; if n==4 mod 16, then a(n) = n+5; if n==12 mod 16, then a(n) = n+2^(A007814(n+4)-2); if n==5 mod 16, then a(n) = n+3; if n==13 mod 16, then a(n) = n+2^(A007814(n+3)-2); if n==6 mod 8, then a(n) = n+2^(A007814(n+2)-2); if n==7 mod 8, then a(n) = n+2^(A007814(n+1)-2).
Using this formula, we can prove conjecture formulated in comment in A209554 in case k=3. Moreover, one can prove that N could be represented in form n<+>2 or n<+>3 iff N is not a number of the forms 32*t, 32*t+1. - Vladimir Shevelev, Apr 25 2012