你们自然有一米。
您需要写一份功能(m),该功能的正数最小,即零度。
换言之,N^n可以分为m。
例如:
f(13) = 13
f(420) = 210
f(666) = 222
f(1234567890) = 411522630
And this is my code for python.
import math
def f(m: int) -> int:
t = math.isqrt(m) + 1
primes = [1 for i in range(0, t)]
maxCount = 0
factors = []
p = 2
result = 1
while p < t and p < m:
if primes[p] == 1 and m % p == 0:
for i in range(p + p, t):
primes[i] = 0
c = 0
while m % p == 0:
m = m // p
c += 1
if maxCount < c:
maxCount = c
result *= p
factors.append(p)
p += 1
factors.append(p)
if m > 1:
result *= m
if maxCount <= result:
return result
p1 = math.ceil(maxCount / result)
for p in primes:
if p >= p1:
return result * p
return result
The problem is, the result is usually gets bigger than it has to be. If you have ever met this question before, please help me how can I solve this problem.
I have tried to find the mathematical methods, and this code is what I have reached so far. I hope this code will get me the smallest result, but it gets bigger than I expected.