DEV Community

Tomashubham
Tomashubham

Posted on

Largest Prime Factor 600851475143

import math
prime=[]
def pf(n):
while(n%2==0):
prime.append(2)
n/=2
for i in range(3,int(math.sqrt(n)),2):
while(n%i==0):
prime.append(i)
n/=i
if(n>2):
prime.append(n)
print(max(prime))
pf(600851475143)

Top comments (0)