login
Multiplicative, with a(p^k) = a(p^k-1) + 2 for any k > 0 and p prime.
2

%I #26 May 08 2022 08:46:07

%S 1,3,5,7,9,15,17,19,21,27,29,35,37,51,45,47,49,63,65,63,85,87,89,95,

%T 97,111,113,119,121,135,137,139,145,147,153,147,149,195,185,171,173,

%U 255,257,203,189,267,269,235,237,291,245,259,261,339,261,323,325,363

%N Multiplicative, with a(p^k) = a(p^k-1) + 2 for any k > 0 and p prime.

%C All terms are odd.

%C Changing the parameter "2" in the name to:

%C - 0 gives the all 1's sequence (A000012),

%C - 1 gives the positive integers (A000027),

%C - -2 gives A351463.

%H Rémy Sigrist, <a href="/A351462/b351462.txt">Table of n, a(n) for n = 1..10000</a>

%H Rémy Sigrist, <a href="/A351462/a351462.png">Scatterplot of the first 100000 terms</a>

%e a(1) = 1 (as this sequence is multiplicative).

%e a(2) = a(1) + 2 = 3.

%e a(3) = a(2) + 2 = 5.

%e a(7) = a(6) + 2 = a(2)*a(3) + 2 = 17.

%e a(42) = a(2)*a(3)*a(7) = 255.

%p a:= proc(n) option remember;

%p mul(a(i[1]^i[2]-1)+2, i=ifactors(n)[2])

%p end:

%p seq(a(n), n=1..58); # _Alois P. Heinz_, Feb 13 2022

%t a[n_] := a[n] = If[n == 1, 1,

%t Product[{p, k} = pk; a[p^k-1]+2, {pk, FactorInteger[n]}]];

%t Table[a[n], {n, 1, 58}] (* _Jean-François Alcover_, May 08 2022 *)

%o (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]))) }

%o (Python)

%o from math import prod

%o from sympy import factorint

%o from functools import cache

%o @cache

%o def a(n):

%o if n == 1: return 1

%o return prod(a(p**k-1)+2 for p, k in factorint(n).items())

%o print([a(n) for n in range(1, 59)]) # _Michael S. Branicky_, Feb 13 2022

%Y Cf. A000012, A000027, A351463.

%K nonn,look,mult

%O 1,2

%A _Rémy Sigrist_, Feb 11 2022