The Arithmetic Derivative The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.


a(0) = a(1) = 0,
a(p) = 1, where p is any prime, and
a(mn) = m*a(n) + n*a(m).


The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules


Write a program or function that, given any integer n, returns the arithmetic derivative of n.
Inputs will be -230 &lt; n &lt; 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.
Built-ins for symbolic math, prime factorization and differentiation are allowed.


Examples

&gt; a(1)
0
&gt; a(7)
1
&gt; a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
&gt; a(-5)   # a(-5) = -a(5) = -1
-1
&gt; a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
&gt; a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
&gt; a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491


As always, if the problem is unclear, please let me know. Good luck and good golfing!
MATL, 12 bytes

|1&gt;?GtYf/s}0


Try it online!

Explanation

Consider an integer a with |a|>1, and let the (possibly repeated) prime factors of |a| be f1, ..., fn. Then the desired result is a·(1/f1 + ... + 1/fn).

|1&gt;     % take input's absolute value. Is it greater than 1?
?       % if so:
  Gt    %   push input twice
  Yf    %   prime factors. For negative input uses its absolute value
  /     %   divide element-wise
  s     %   sum of the array
}       % else:
  0     %   push 0