A055095 a(n) = 2*A000120(A003188(A055094(n))) - (n-1) = 2*A005811(A055094(n)) - (n-1).
0, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 1, 2, 3, 2, -3, 2, 7, 2, -3, 4, 3, 2, -3, 14, 1, 10, -3, 2, 3, 2, -11, 4, 1, -2, -7, 2, 3, 2, -11, 2, 7, 2, -7, -4, 3, 2, -19, 8, 25, 2, -11, 2, 19, -6, -15, 4, 1, 2, -19, 2, 3, -6, -23, -10, 7, 2, -15, 4, -5, 2, -27, 2, 1, 6, -15, -4, 3, 2, -39, 28, 1, 2, -27, -14, 3, 2, -27, 2, -9, -10, -19, 4, 3, -14, -47, 2, 15, -14, -19, 2, 3, 2, -35, -24
Offset: 1
Keywords
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
Programs
-
Maple
A055095 := proc(n) 2*A005811(A055094(n))-n+1 ; end proc: seq(A055095(n),n=1..20) ; # R. J. Mathar, Mar 10 2015
-
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]&; a[1] = 0; a[n_] := 2*A005811[A055094[n]] - (n-1); Array[a, 105] (* Jean-François Alcover, Mar 05 2016 *)
-
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
Formula
a(n) = (2*wt(GrayCode(qrs2bincode(n))))-(n-1).
Comments