Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Arithmetic-derivative/Python/arithmetic-derivative.py
Normal file
19
Task/Arithmetic-derivative/Python/arithmetic-derivative.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from sympy.ntheory import factorint
|
||||
|
||||
def D(n):
|
||||
if n < 0:
|
||||
return -D(-n)
|
||||
elif n < 2:
|
||||
return 0
|
||||
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()])
|
||||
|
||||
for n in range(-99, 101):
|
||||
print('{:5}'.format(D(n)), end='\n' if n % 10 == 0 else '')
|
||||
|
||||
print()
|
||||
for m in range(1, 21):
|
||||
print('(D for 10**{}) divided by 7 is {}'.format(m, D(10 ** m) // 7))
|
||||
Loading…
Add table
Add a link
Reference in a new issue