OFFSET
1,2
COMMENTS
Multiplicative because A322577 is.
LINKS
Sebastian Karlsson, Table of n, a(n) for n = 1..10000
FORMULA
MATHEMATICA
f[p_, e_] := If[EvenQ[e], p^2 + 1, -2*p]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Oct 23 2023 *)
PROG
(PARI)
up_to = 16384;
A001615(n) = if(1==n, n, my(f=factor(n)); prod(i=1, #f~, f[i, 1]^f[i, 2] + f[i, 1]^(f[i, 2]-1))); \\ After code in A001615
DirInverseCorrect(v) = { my(u=vector(#v)); u[1] = (1/v[1]); for(n=2, #v, u[n] = (-u[1]*sumdiv(n, d, if(d<n, v[n/d]*u[d], 0)))); (u) }; \\ Compute the Dirichlet inverse of the sequence given in input vector v.
v347092 = DirInverseCorrect(vector(up_to, n, A322577(n)));
A347092(n) = v347092[n];
(PARI) A347092(n) = { my(f=factor(n)); prod(i=1, #f~, if(f[i, 2]%2, -2*f[i, 1], 1+(f[i, 1]^2))); }; \\ (after Sebastian Karlsson's multiplicative formula) - Antti Karttunen, Nov 11 2021
(Haskell)
import Math.NumberTheory.Primes
a n = product . map (\(p, e) -> if even e then 1 + unPrime p^2 else -2*unPrime p) . factorise $ n -- Sebastian Karlsson, Oct 29 2021
(Python)
from sympy import factorint, prod
def f(p, e): return 1 + p**2 if e%2 == 0 else -2*p
def a(n):
factors = factorint(n)
return prod(f(p, factors[p]) for p in factors) # Sebastian Karlsson, Oct 29 2021
CROSSREFS
KEYWORD
sign,easy,mult
AUTHOR
Antti Karttunen, Aug 18 2021
STATUS
approved