Arithmetic derivative: Difference between revisions

Line 85:
 
=={{header|Python}}==
{{incorrect|python|4=D(4)}}
<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 -1108 -176
-1 -71 -18 -80 -55 -39 -1 -156 -1 -59
-26 -72 -1 -61 -18 -1192 -51 -33 -1 -92
-1 -31 -22 -92 -16 -81 -1 -56 -20 -45
-114 -112 -1 -25 -39 -48 -1 -41 -1 -68
-16 -21 -1 -60 -12 -19 -14 -180 -1 -31
-1 -32 -127 -15 -110 -44 -1 -13 -10 -24
-1 -21 -1 -132 -8 -9 -1 -16 -1 -7
-1 6 -112 -1 -5 -1 -14 -1 -1 0 0
0 1 1 14 1 5 1 12 1 16 7
1 16 1 9 8 132 1 21 1 24
10 13 1 44 110 15 127 32 1 31
1 180 14 19 12 60 1 21 16 68
1 41 1 48 39 25 1 112 114 45
20 56 1 81 16 92 22 31 1 92
1 33 51 1192 18 61 1 72 26 59
1 156 1 39 55 80 18 71 1 176
1108 43 1 124 22 45 32 140 1 123
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
4,105

edits