OFFSET
1,4
EXAMPLE
For n=12, sigma^{4}(12)-1 = 360-1 = 359 is prime, and there is no positive k<4 such that sigma^{k}(12)-1 is prime, so a(12)=4.
MAPLE
sigma_iterate := proc (n, k)
local sigma_result, i:
sigma_result := n:
for i to k do
sigma_result := sigma(sigma_result)
end do:
return sigma_result
end proc:
find_min_k := proc (n)
local k, sigma_k_n, prime_candidate:
k := 0:
do
k := k+1:
sigma_k_n := sigma_iterate(n, k):
prime_candidate := sigma_k_n - 1:
if isprime(prime_candidate) then
return k
end if
end do
end proc:
map(find_min_k, [$ 2 .. 100]);
MATHEMATICA
A374163[n_] := If[n==1, 1, Length[NestWhileList[DivisorSigma[1, #]&, n, !PrimeQ[# - 1]&, {2, 1}]] - 1]; Array[A374163, 100] (* Paolo Xausa, Jul 24 2024 *)
PROG
(PARI) a(n) = my(k=1, s=sigma(n)); while(!isprime(s-1), k++; s = sigma(s)); k; \\ Michel Marcus, Jun 29 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Rafik Khalfi, Jun 29 2024
EXTENSIONS
Offset corrected by N. J. A. Sloane, Jul 25 2024
STATUS
approved