I am trying to find out the largest prime factor of any number. I am doing the program for this problem in python, but there seems to be something wrong with the algorithm that I am following. It seems to fall into an infinite loop. The program goes like this:
def prime(n):
i=0;
while(n!=2):
for i in range(2,n):
if(n%i==0):
prime(n/i);
else:
continue;
print("The highest prime factor is: "),n;
print("Enter a number to find its highest prime factor");
n=input();
prime(n);
Just point out what are the problems here and also mention if there are any other better algorithm than this one for solving this.