OFFSET
1,3
COMMENTS
REFERENCES
See problem 9.2.2 in Elementary Number Theory by David M. Burton, ISBN 0-205-06978-9
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..4096
FORMULA
a(n) = (2*wt(GrayCode(qrs2bincode(n))))-(n-1).
MAPLE
MATHEMATICA
A005811[n_] := Length[Length /@ Split[IntegerDigits[n, 2]]];
A055094[n_] := With[{rr = Table[Mod[k^2, n], {k, 1, n-1}] // Union}, Boole[ MemberQ[rr, #]]& /@ Range[n-1]] // FromDigits[#, 2]&;
Array[a, 105] (* Jean-François Alcover, Mar 05 2016 *)
PROG
(Python)
from sympy.ntheory.residue_ntheory import quadratic_residues as q
def a055094(n):
Q=q(n)
z=0
for i in range(1, n):
z*=2
if i in Q: z+=1
return z
def a005811(n): return bin(n^(n>>1))[2:].count("1")
def a(n): return 0 if n == 1 else 2*a005811(a055094(n)) - (n - 1) # Indranil Ghosh, May 13 2017
CROSSREFS
KEYWORD
sign
AUTHOR
Antti Karttunen, Apr 04 2000
STATUS
approved