Every natural number, ```n```, may have a prime factorization like:



We define the **geometric derivative of n**, as a number with the following value:



For example: calculate the value of ```n*``` for ```n = 24500```.
```
24500 = 2²5³7²
n* = (2*2) * (3*5²) * (2*7) = 4200
```
Make a function, ```f``` that can perform this calculation
```
f(n) ----> n*
```
Every prime number will have ```n* = 1```.

Every number that does not have an exponent ```ki```, higher than 1, will give a ```n* = 1```, too

```python
f(24500) == 4200

f(997) == 1
```
Do your best!

Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code:
def f(n):
	

Solutions:
def f(n):
	res = 1
	i = 2
	while n != 1:
		k = 0
		while n % i == 0:
			k += 1
			n //= i
		if k != 0:
			res *= k * i ** (k - 1)
		i += 1
	return res


def f(n):
	(p, n_, m) = (2, 1, int(n ** 0.5))
	while n > 1 and p <= m:
		k = 0
		while not n % p:
			k += 1
			n //= p
		if k:
			n_ *= k * p ** (k - 1)
		p += 1
	return n_


from collections import Counter

def prime_factors(n):
	p = []
	while n % 2 == 0:
		p.append(2)
		n /= 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			p.append(i)
			n /= i
	if n > 2:
		p.append(int(n))
	return p

def f(n):
	fac = Counter(prime_factors(n))
	re = 1
	for i in fac.keys():
		re *= fac[i] * i ** (fac[i] - 1)
	return re


import math
import numpy as np

def f(n):
	if set(primeFactors(n).values()) == {1}:
		return 1
	return np.prod([v * k ** (v - 1) for (k, v) in primeFactors(n).items()])

def primeFactors(n):
	ans = dict()
	cnt2 = 0
	while n % 2 == 0:
		cnt2 += 1
		ans.update({2: cnt2})
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		cnti = 0
		while n % i == 0:
			cnti += 1
			ans.update({i: cnti})
			n = n / i
	if n > 2:
		ans.update({n: 1})
	return ans


def f(n):
	factors = []
	i = 2
	while n > 1:
		if n % i == 0:
			n = n / i
			factors.append(i)
		else:
			i += 1
	from collections import Counter
	from numpy import prod
	return prod([occurences * factor ** (occurences - 1) for (factor, occurences) in Counter(factors).items()])


def f(num):
	dic = {}
	while True:
		for i in range(2, int(num ** 0.5) + 1):
			if num % i == 0:
				num /= i
				if i in dic:
					dic[i] += 1
				else:
					dic[i] = 1
				break
		else:
			if num in dic:
				dic[num] += 1
			else:
				dic[num] = 1
			break
		continue
	ans = 1
	for item in dic:
		ans *= dic[item] * item ** (dic[item] - 1)
	return ans


def f(n):
	r = 1
	c = 0
	pf = primef(n)
	pf.append(-1)
	m = pf[0]
	for i in pf:
		if i == m:
			c += 1
		else:
			r *= c * m ** (c - 1)
			m = i
			c = 1
	return r

def primef(n):
	i = 2
	f = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			f.append(i)
	if n > 1:
		f.append(n)
	return f


from functools import reduce

def f(n):
	facts = factorization(n)
	return mul((power * prime ** (power - 1) for (prime, power) in facts))

def mul(ar):
	return reduce(lambda x, y: x * y, ar)

def factorization(n):
	result = []
	i = 2
	while i * i <= n:
		if n % i == 0:
			power = 0
			while n % i == 0:
				power += 1
				n /= i
			result.append((i, power))
		i += 1
	if n > 1:
		result.append((n, 1))
	return result


from collections import Counter

def f(n):
	i = 3
	sum = 1
	lists = []
	while (n / 2).is_integer():
		lists.append(2)
		n //= 2
	while n != 1 and i <= n:
		while n % i == 0:
			lists.append(i)
			n //= i
		i += 2
	for i in dict(Counter(lists)):
		a = dict(Counter(lists))[i]
		sum *= a * i ** (a - 1)
	return sum