OFFSET
1,2
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, Scatterplot of the first 100000 terms
EXAMPLE
a(1) = 1 (as this sequence is multiplicative).
a(2) = a(1) + 2 = 3.
a(3) = a(2) + 2 = 5.
a(7) = a(6) + 2 = a(2)*a(3) + 2 = 17.
a(42) = a(2)*a(3)*a(7) = 255.
MAPLE
a:= proc(n) option remember;
mul(a(i[1]^i[2]-1)+2, i=ifactors(n)[2])
end:
seq(a(n), n=1..58); # Alois P. Heinz, Feb 13 2022
MATHEMATICA
a[n_] := a[n] = If[n == 1, 1,
Product[{p, k} = pk; a[p^k-1]+2, {pk, FactorInteger[n]}]];
Table[a[n], {n, 1, 58}] (* Jean-François Alcover, May 08 2022 *)
PROG
(PARI) a(n) = { my (f=factor(n)); if (#f~==1, a(n-1)+2, prod (k=1, #f~, a(f[k, 1]^f[k, 2]))) }
(Python)
from math import prod
from sympy import factorint
from functools import cache
@cache
def a(n):
if n == 1: return 1
return prod(a(p**k-1)+2 for p, k in factorint(n).items())
print([a(n) for n in range(1, 59)]) # Michael S. Branicky, Feb 13 2022
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Feb 11 2022
STATUS
approved