Given a certain integer ```n```, we need a function ```big_primefac_div()```, that give an array with the highest prime factor and the highest divisor (not equal to n).

Let's see some cases:
```python
big_primefac_div(100) == [5, 50]
big_primefac_div(1969) == [179, 179]
```
If n is a prime number the function will output an empty list:
```python
big_primefac_div(997) == []
```
If ```n``` is an negative integer number, it should be considered the division with tha absolute number of the value.
```python
big_primefac_div(-1800) == [5, 900]
```
If ```n``` is a float type, will be rejected if it has a decimal part with some digits different than 0. The output "The number has a decimal part. No Results". But  ```n ``` will be converted automatically to an integer if all the digits of the decimal part are 0.

```python
big_primefac_div(-1800.00) == [5, 900]
big_primefac_div(-1800.1) == "The number has a decimal part. No Results"
```
Optimization and fast algorithms are a key factor to solve this kata.
Happy coding and enjoy it!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def big_primefac_div(n):
	

Solutions:
def big_primefac_div(n):
	(bpf, bd) = (0, 1)
	frac = []
	if n % 1 != 0:
		return 'The number has a decimal part. No Results'
	else:
		n = abs(int(n))
		n_copy = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			n //= i
			frac.append(i)
		else:
			i += 1
	if n > 1:
		frac.append(n)
	bpf = max(frac)
	bd = n_copy / frac[0]
	if bpf == 0 or bd == 1:
		return []
	else:
		return [bpf, bd]


def big_primefac_div(n):
	n = abs(n)
	maxi = 0
	if n % 1 == 0:
		listy = [num for num in range(2, int(n ** 0.5 + 1)) if n % num == 0]
		fancy_list = list(listy)
		for number in listy:
			temp_numb = n // number
			fancy_list.append(int(temp_numb))
		for numb in sorted(fancy_list, reverse=True):
			for i in range(2, int(numb ** 0.5 + 1)):
				if numb % i == 0:
					break
			else:
				maxi = numb
				break
		if fancy_list:
			return [maxi, max(set(fancy_list))]
		else:
			return []
	else:
		return 'The number has a decimal part. No Results'


import math

def primecheck(num):
	a = math.sqrt(num)
	for i in range(2, int(a + 2)):
		if num % i == 0:
			return False
	return True
print(primecheck(25))

def big_primefac_div(n):
	if int(n) != n:
		return 'The number has a decimal part. No Results'
	n = abs(n)
	factor = []
	prime = []
	for i in range(2, int(math.sqrt(n) + 1)):
		if n % i == 0:
			factor.append(i)
			factor.append(n / i)
	for j in factor:
		if primecheck(j) is True:
			prime.append(j)
	if len(factor) == 0:
		return []
	factor.sort()
	prime.sort()
	return [int(prime[-1]), int(factor[-1])]


def big_primefac_div(n):
	if n % 1:
		return 'The number has a decimal part. No Results'
	o = n = abs(int(n))
	(mn, mx) = (0, 1)
	while n % 2 == 0:
		(mn, mx, n) = (mn or 2, 2, n // 2)
	k = 3
	while k * k <= n:
		if n % k:
			k = k + 2
		else:
			(mn, mx, n) = (mn or k, k, n // k)
	return [max(mx, n), o // mn] if mn else []


from itertools import count

def big_primefac_div(n):
	prime = lambda n: all((n % i for i in range(2, int(n ** 0.5) + 1)))
	if n != int(n):
		return 'The number has a decimal part. No Results'
	if prime(abs(n)):
		return []
	f = factor(abs(n))
	return [max(f), abs(n) / f[0]]

def factor(n):
	(j, li) = (2, [])
	while j * j <= n:
		if n % j == 0:
			n //= j
			li.append(j)
		else:
			j += 1
	if n > 1:
		li.append(n)
	return li


def big_primefac_div(n):
	if n % 1:
		return 'The number has a decimal part. No Results'
	n = abs(int(n))
	mpf = big_primefac(n)
	return [mpf, big_div(n)] if mpf != n else []

def big_primefac(n):
	m = 1
	while n % 2 == 0:
		(m, n) = (2, n // 2)
	k = 3
	while k * k <= n:
		if n % k:
			k = k + 2
		else:
			(m, n) = (k, n // k)
	return max(m, n)

def big_div(n):
	return next((n // k for k in range(2, int(n ** 0.5) + 1) if n % k == 0), n)


def big_primefac_div(n):
	if n % 1 != 0:
		return 'The number has a decimal part. No Results'
	n = -n if n < 0 else n
	biggest_divisor = 1
	biggest_primefactor = 1
	if n % 2 == 0:
		biggest_primefactor = 2
	elif n % 3 == 0:
		biggest_primefactor = 3
	else:
		i = 5
		while i * i <= n:
			if n % i == 0:
				biggest_primefactor = i
				break
			elif n % (i + 2) == 0:
				biggest_primefactor = i + 2
				break
			i = i + 6
	if biggest_primefactor == 1:
		return []
	biggest_divisor = n / biggest_primefactor
	n = int(n)
	while n % 2 == 0:
		biggest_primefactor = 2
		n >>= 1
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			biggest_primefactor = i
			n = n / i
	if n > 2:
		biggest_primefactor = n
	return [biggest_primefactor, biggest_divisor]


def big_primefac_div(n):
	n = abs(n)
	if isinstance(n, float):
		temp = str(n)[str(n).index('.') + 1:]
		for i in temp:
			if i != '0':
				return 'The number has a decimal part. No Results'
	res = factorization(n)
	if len(res) == 1:
		return []
	return [res[-1], n // res[0]]

def factorization(n):
	factor = 2
	res = []
	while factor * factor <= n:
		if n % factor == 0:
			n //= factor
			res.append(factor)
			factor = 2
		else:
			factor += 1
	res.append(int(n))
	return res


def pf(n):
	(p, x) = ([], 2)
	while x * x <= n:
		while not n % x:
			n //= x
			p.append(x)
		x += 1
	if n > 1:
		p.append(n)
	return p

def big_primefac_div(n):
	if isinstance(n, float) and (not n.is_integer()):
		return 'The number has a decimal part. No Results'
	n = abs(n)
	p = pf(n)
	return [p[-1], n // p[0] if n % 2 else n // 2] if p[-1] != n else []