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.

A362951 a(n) is the Hamming distance between the binary expansions of n and phi(n) where phi is the Euler totient function (A000010).

Original entry on oeis.org

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

Views

Author

DarĂ­o Clavijo, Jul 05 2023

Keywords

Comments

a(2^k) = 2 for k >= 1.
a(p) = 1 for each odd prime p because phi(p) = p-1 and (p-1 xor p) = 1.

Crossrefs

Programs

  • Mathematica
    A362951[n_] := DigitCount[BitXor[n, EulerPhi[n]], 2, 1];
    Array[A362951, 100] (* Paolo Xausa, Feb 20 2024 *)
  • Python
    from gmpy2 import mpz, hamdist
    from sympy import totient
    a = lambda n: hamdist(mpz(n), mpz(totient(n)))
    print([a(n) for n in range(1, 87)])
    
  • Python
    from sympy import totient
    def A362951(n): return (n^totient(n)).bit_count() # Chai Wah Wu, Jul 07 2023

Formula

a(n) = A101080(n,A000010(n)).
a(n) = A000120(A169814(n)).