OFFSET
1,18
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..10000
FORMULA
a(1) = 1, and for n > 1, a(n) = 1 - Sum_{2 <= k <= n-1} [gcd(k,n)>1]*a(k), where [ ] is the Iverson bracket. - Antti Karttunen, Feb 22 2023
EXAMPLE
The positive integers which are <= 6 and are not coprime to 6 are 2,3,4,6. And a(6) is such that a(2)+a(3)+a(4)+a(6) = 1, i.e. a(6) = 1 - (a(2)+a(3)+a(4)) = 1 - 2 = -1.
The positive integers which are <= 12 and are not coprime to 12 2,3,4,6,8,9,10,12. And a(12) is such that a(2)+a(3)+a(4)+a(6)+a(8)+a(9)+a(10)+a(12) = 1.
MATHEMATICA
f[n_] := Select[Range[2, n], GCD[ #, n] > 1 &]; g[l_] :=Append[l, 1 - Plus @@ l[[Most[f[Length[l] + 1]]]]]; Nest[g, {1}, 85] (* Ray Chandler, Nov 13 2006 *)
PROG
(PARI)
up_to_n = 10000;
A124385list(up_to_n) = { my(v=vector(up_to_n)); v[1] = 1; for(n=2, up_to_n, v[n] = 1-sum(k=2, n-1, (gcd(k, n)>1)*v[k])); (v); };
v124385 = A124385list(up_to_n);
A124385(n) = v124385[n]; \\ Antti Karttunen, Feb 22 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Leroy Quet, Oct 29 2006
EXTENSIONS
Extended by Ray Chandler, Nov 13 2006
STATUS
approved