OFFSET
1,3
COMMENTS
A family of related sequences can be generated using different positive integers for a(1).
LINKS
Peter Kagey, Table of n, a(n) for n = 1..10000
FORMULA
If, for a given fixed a(1), b(n,j) = number of a(k)'s which are multiples of j, for 1 <= k <= n-1, then: a(n) = Sum_{j|n} mu(j)*b(n,j), where mu(j) is the Moebius (Möbius) function.
EXAMPLE
a(1)=1, a(2)=1 and a(9)=7 are those terms, prior to a(10), which are coprime with 10. So a(10) = 3.
MAPLE
a[1]:=1: for n from 2 to 100 do B:=[seq(gcd(n, a[j]), j=1..n-1)]; s:=0: for i from 1 to n-1 do if B[i]=1 then s:=s+1 else s:=s: fi: od: a[n]:=s: od: seq(a[n], n=1..85); # Emeric Deutsch, Aug 01 2005
MATHEMATICA
a[1] = 1; a[n_] := a[n] = Count[ GCD[ Table[ a[i], {i, n - 1}], n], 1]; Table[ a[n], {n, 80}] (* Robert G. Wilson v, Jul 30 2004 *)
PROG
(Perl) #!/usr/bin/perl -w
use bigint; # only because it is an easy way to get gcd()
$| = $n = 1;
@a = (0);
while (1) {
$v = grep $n->bgcd($_) == 1, @a;
print $a[ $n++ ] = $v, " ";
} # Hugo van der Sanden, Mar 30 2006
(PARI) lista(nn) = {va = vector(nn); print1(va[1]=1, ", "); for (n=2, nn, va[n] = sum(k=1, n-1, gcd(va[k], n) == 1); print1(va[n], ", "); ); } \\ Michel Marcus, Apr 10 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Jul 28 2004
EXTENSIONS
Edited and extended by Robert G. Wilson v, Jul 30 2004
STATUS
approved