I have to calculate an integer $n$ when an integer $m$ is given, that $n^n$ is divisible by $m$. And the thing is, $n$ is the smallest number that satisfies this condition. Please help me how can I solve this using mathematics.
This is the python code that I have tried.
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
In the code, I get all the primes that made $m$. And my work was to get every $p$, for every prime to $\mathrm{prime}^p$. With my code, I get the $n$ that is $n^n$ is divisible by $m$, but in some cases it was not the smallest.