I have the problem in pic related.
I've written some code to solve it but iterating from 10^8 to 10^14 is really slow.
I attempted to implement code to solve it
[code:lit]
from sympy.ntheory import factorint
from sympy.ntheory.factor_ import primeomega
def slow_f(n):
return 2 ** primeomega(n)
def f(n):
if n == 1:
return 1
return 2 ** sum(list(factorint(n).values()))
def S(N):
start_value = 0
total = 0
if N == 10 ** 8:
return 9613563919
if N > 10 ** 8:
start_value = 10 ** 8
total = 9613563919
for i in range(start_value + 1, N+1):
total += f(i)
return total
print(S(10**14))
[/code:lit]
Is there a better way? I'm not seeing any obvious shortcuts that I can take.
I've written some code to solve it but iterating from 10^8 to 10^14 is really slow.
I attempted to implement code to solve it
[code:lit]
from sympy.ntheory import factorint
from sympy.ntheory.factor_ import primeomega
def slow_f(n):
return 2 ** primeomega(n)
def f(n):
if n == 1:
return 1
return 2 ** sum(list(factorint(n).values()))
def S(N):
start_value = 0
total = 0
if N == 10 ** 8:
return 9613563919
if N > 10 ** 8:
start_value = 10 ** 8
total = 9613563919
for i in range(start_value + 1, N+1):
total += f(i)
return total
print(S(10**14))
[/code:lit]
Is there a better way? I'm not seeing any obvious shortcuts that I can take.
