Arithmetic derivative: Difference between revisions
→{{header|Python}}
(→{{header|Python}}: 4=D(4)) |
|||
Line 85:
=={{header|Python}}==
<lang python>from sympy.ntheory import factorint
Line 95 ⟶ 94:
else:
fdict = factorint(n)
if len(fdict) == 1 and 1 in fdict: # is prime
return 1
return sum([n * e // p for p, e in fdict.items()])
Line 109 ⟶ 108:
<pre>
-75 -77 -1 -272 -24 -49 -34 -96 -20 -123
-1 -140 -32 -45 -22 -124 -1 -43
-1 -71 -18 -80 -55 -39 -1 -156 -1 -59
-26 -72 -1 -61 -18
-1 -31 -22 -92 -16 -81 -1 -56 -20 -45
-16 -21 -1 -60 -12 -19 -14
-1 -32
-1 -21 -1
-
0 1 1
1 16 1 9 8
10 13 1 44
1
1 41 1 48 39 25 1 112
20 56 1 81 16 92 22 31 1 92
1 33 51
1 156 1 39 55 80 18 71 1 176
20 96 34 49 24 272 1 77 75 140
{2: 2}
(D for 10**1) divided by 7 is 1
(D for 10**2) divided by 7 is 20
|