login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Largest n-digit number coprime to n.
0

%I #8 Dec 05 2013 19:57:00

%S 9,99,998,9999,99999,999997,9999999,99999999,999999998,9999999999,

%T 99999999999,999999999997,9999999999999,99999999999999,

%U 999999999999998,9999999999999999,99999999999999999,999999999999999997

%N Largest n-digit number coprime to n.

%C a(286) = 10^286 - 5 is the first term with a(n) < 10^n - 3. - Rick L. Shepherd

%t f[n_] := Block[{k=10^n-1}, While[ GCD[n, k]>1, k-- ]; k]; Table[ f[n], {n, 18}] (* _Robert G. Wilson v_ *)

%o (PARI) for(n=1,300,m=10^n-1;while(gcd(m,n)>1,m--);print1(m,",")) (Rick L. Shepherd)

%K base,easy,nonn

%O 1,1

%A _Amarnath Murthy_, Jul 19 2005

%E More terms from _Rick L. Shepherd_ and _Robert G. Wilson v_, Jul 21 2005