OFFSET
1,2
COMMENTS
The least index n such that a(n) = prime(k) is A002110(k).
Let p be a prime and prev(p) = A151799(p) if p >= 3, and prev(2) = 1 (i.e., prev(p) is the largest noncomposite number that is smaller than p). Then, the asymptotic density of the occurrences of prev(p) in this sequence is 1/prev(p)# - 1/p#, where # denotes primorial (second definition, A034386). For example, the asymptotic densities of the occurrences of 1, 2, 3, 5 and 7 are 1/2, 1/3, 2/15, 1/35 and 1/231, respectively.
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
a(30) = 5 since 30 is divisible by all the primes <= 5, i.e., by 2, 3 and 5.
MATHEMATICA
a[n_] := Module[{p = 1}, While[Divisible[n, p], p = NextPrime[p]]; If[p > 2, NextPrime[p, -1], 1]]; Array[a, 100]
PROG
(PARI) a(n) = {my(p = 1); while(!(n % p), p = nextprime(p+1)); if(p > 2, precprime(p-1), 1); }
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Amiram Eldar, Oct 11 2024
STATUS
approved