login
a(1)=1. a(n) = number of positive integers that are < n, are coprime to n and do not occur among the first n-1 terms of the sequence.
1

%I #14 Jul 19 2016 11:06:47

%S 1,0,1,1,3,1,4,2,3,2,6,3,7,4,4,5,9,3,10,4,7,5,13,4,12,7,11,6,16,4,17,

%T 8,10,9,12,6,21,9,14,8,23,6,24,11,13,13,27,9,25,10,19,12,30,9,22,13,

%U 21,15,33,9,34,15,21,17,27,12,39,17,28,13,41,14,42,19,24,20,36,15,45

%N a(1)=1. a(n) = number of positive integers that are < n, are coprime to n and do not occur among the first n-1 terms of the sequence.

%e The positive integers which are both less than 9 and are coprime to 9 are 1, 2, 4, 5, 7 and 8. Of these, only the three integers 5, 7 and 8 do not occur earlier in the sequence, so a(9)=3.

%o (Perl) #!/usr/bin/perl -w

%o use Math::PARI qw/ gcd eulerphi /;

%o $| = 1;

%o $n = 2;

%o %seen = (1 => 1);

%o while (1) {

%o $v = eulerphi($n) - grep gcd($n, $_) == 1, keys %seen;

%o $seen{$v} = 1;

%o ++$n;

%o print "$v ";

%o } # from _Hugo van der Sanden_, Mar 30 2006

%Y Cf. A096216.

%K nonn

%O 1,5

%A _Leroy Quet_, Mar 27 2006

%E More terms from _Hugo van der Sanden_, Mar 31 2006