%I #20 Jun 10 2026 08:32:53
%S 3,4,4,5,3,5,3,5,4,4,3,7,3,4,4,5,3,5,3,6,4,4,3,7,3,4,4,5,3,7,3,5,4,4,
%T 3,7,3,4,4,6,3,5,3,5,4,4,3,7,3,4,4,5,3,5,3,5,4,4,3,8,3,4,4,5,3,5,3,5,
%U 4,4,3,7,3,4,4,5,3,5,3,6,4,4,3,8,3,4,4,5,3,7,3,5,4
%N Second least non-divisor of n.
%C An integer m >= 3 appears in the sequence if and only if m is a prime power or twice a prime power.
%H David Radcliffe, <a href="/A396771/b396771.txt">Table of n, a(n) for n = 1..10000</a>
%H Bakir Farhi, <a href="http://www.integers-ejcnt.org/j42/j42.Abstract.html">On the average asymptotic behavior of a certain type of sequences of integers</a>, Integers 9 (2009), 555-567.
%F Sum_{n=1..N} a(n) = c*N + O((log N)^2 / (log log N)), where
%F c = Sum_{m >= 0} (1 + Sum_{m/2 < p^a <= m} (p-1)) / lcm(1,2,...,m) ~ 4.287434141625.
%t f[n_, q_ : 1] := Module[{c, k}, c = 0; k = 2; While[If[! Divisible[n, k], c++]; c < q, k++]; k]; Table[f[n, 2], {n, 120}] (* _Michael De Vlieger_, Jun 08 2026 *)
%o (Python)
%o from itertools import count, islice
%o def A396771(n: int, rank: int = 2) -> int:
%o assert n > 0 and rank > 0, "Arguments must be positive integers."
%o return next(islice(filter(lambda x: n % x, count(2)), rank - 1, rank))
%o (PARI) a(n) = my(nb=0, i=1); while(nb !=2, i++; if (n % i, nb++)); i; \\ _Michel Marcus_, Jun 08 2026
%Y Cf. A007978, A140485.
%K nonn,easy
%O 1,1
%A _David Radcliffe_, Jun 04 2026