Von Mangoldt function with PARI GP

arithmetic-functionselementary-number-theorynumber theoryprogramming

How to program the Von Mangoldt function:
$$\Lambda (n)=\begin{cases}\log p&{\text{if }}n=p^{k}{\text{ for some prime }}p{\text{ and integer }}k\geq 1,\\0&{\text{otherwise.}}\end{cases}$$

with PARI/GP.Thank you.

Best Answer

An implementation for the function in Pari/GP:

Mangoldt(n)={ispower(n,,&n);if(isprime(n),log(n),0)};

For the exponential of Mangoldt function A014963 type:

A014963(n)={round(exp(Mangoldt(n)))};