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.

A205509 Hamming distance between (n-1)! and n!.

Original entry on oeis.org

0, 2, 1, 4, 2, 4, 4, 6, 4, 9, 8, 15, 12, 16, 14, 12, 16, 23, 26, 23, 21, 29, 31, 34, 31, 33, 33, 44, 32, 38, 42, 46, 52, 51, 45, 55, 55, 59, 55, 59, 51, 82, 65, 83, 74, 75, 80, 80, 80, 74, 87, 104, 86, 91, 98, 90, 81, 103, 104, 98, 112, 104, 111, 116, 111, 132
Offset: 1

Views

Author

Vladimir Shevelev, Jan 28 2012

Keywords

Comments

Problem: To find a better lower estimate for a(n) than the trivial one, which is a(n) >= A000120(floor(log_2(n))).
Note that this trivial estimate yields unboundedness of the sequence.

Examples

			Since 5!=(0001111000)_2 and 6!=(1011010000)_2, then the number of different binary digits is 4. Therefore, a(6)=4.
		

Crossrefs

Cf. A001511.

Programs

  • Maple
    read("transforms") :
    Hamming := proc(a,b)
            XORnos(a,b) ;
            wt(%) ;
    end proc:
    A205509 := proc(n)
            Hamming((n-1)!,n!) ;
    end proc: # R. J. Mathar, Apr 02 2012
  • Mathematica
    nn = 100; Table[b2 = IntegerDigits[n!, 2]; b1 = IntegerDigits[(n - 1)!, 2, Length[b2]]; Total[Abs[b1 - b2]], {n, nn}] (* T. D. Noe, Jan 31 2012 *)
  • Python
    from math import factorial
    def A205509(n): return ((f:=factorial(n-1))^f*n).bit_count() # Chai Wah Wu, Jul 13 2022
  • Sage
    def A205509(n) :
        f = bin(factorial(n)).lstrip("0b")
        g = bin(factorial(n-1)).lstrip("0b")
        h = "".zfill(len(f)-len(g)) + g
        return sum(a != b for a, b in zip(f, h))
    [A205509(k) for k in (1..66)] # Peter Luschny, Jan 31 2012