A118310 a(n) = gcd(n,m(n)), where m(n) is the n-th nonprime positive integer (1 or composite).
1, 2, 3, 4, 1, 2, 1, 2, 3, 2, 1, 4, 1, 2, 3, 1, 1, 9, 1, 10, 1, 11, 1, 1, 1, 2, 3, 4, 1, 2, 1, 2, 3, 1, 5, 3, 1, 2, 1, 8, 1, 2, 1, 2, 9, 2, 1, 6, 1, 1, 1, 4, 1, 3, 1, 7, 3, 2, 1, 2, 1, 1, 1, 1, 1, 6, 1, 4, 3, 2, 1, 24, 1, 1, 25, 2, 1, 3, 1, 4, 1, 1, 1, 6, 5, 2, 3, 2, 1, 30, 1, 2, 3, 2, 5, 6, 1, 1, 1, 4, 1, 2, 1
Offset: 1
Links
- Antti Karttunen, Table of n, a(n) for n = 1..20000
Crossrefs
Cf. A064814.
Programs
-
Mathematica
NonPrime[n_Integer] := FixedPoint[n + PrimePi@# &, n + PrimePi@n]; f[n_] := GCD[n, NonPrime@n]; Array[f, 103] (* Robert G. Wilson v *)
-
PARI
A002808(maxn)= { local(a); a=[4]; for(n=5,maxn, if( !isprime(n), a=concat(a,n); ); ); return(a); } A118310(maxn)= { local(nonppo,a,newa,nonppol); a=[;]; nonppo=concat(1,A002808(maxn)); nonppol=matsize(nonppo); for(n=1,nonppol[2], newa= gcd(n, nonppo[n]); a=concat(a,newa); ); return(a); } print(A118310(180)); \\ R. J. Mathar
-
PARI
A118310(n) = if(1==n, n, my(x=n-1); for(k=2, oo, if(!isprime(k), x--; if(!x, return(gcd(n,k)))))); \\ Antti Karttunen, Mar 02 2023
Extensions
More terms from Robert G. Wilson v and R. J. Mathar, May 16 2006
Comments