Blame view

3.py 477 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python

import math;
import sys;

def factor(num):
	higherFactor = -1;
	for i in range (2,int(math.sqrt(num))+1):
		if((num % i) == 0):
			newFactor = factor(i);
			if(newFactor > higherFactor):
				higherFactor = newFactor;
			newFactor = factor(num/i);
			if(newFactor > higherFactor):
				higherFactor = newFactor;
			return higherFactor;

	if(num > higherFactor):
		higherFactor = num;

	return higherFactor;

print "Result is: " + str(factor(int(sys.argv[1])));