mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-27 10:22:36 +08:00
Modernize Python 2 code to get ready for Python 3
This commit is contained in:
@ -3,6 +3,7 @@ Problem:
|
||||
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import math
|
||||
|
||||
@ -20,12 +21,12 @@ def isprime(no):
|
||||
max=0
|
||||
n=int(input())
|
||||
if(isprime(n)):
|
||||
print n
|
||||
print(n)
|
||||
else:
|
||||
while (n%2==0):
|
||||
n=n/2
|
||||
if(isprime(n)):
|
||||
print n
|
||||
print(n)
|
||||
else:
|
||||
n1 = int(math.sqrt(n))+1
|
||||
for i in range(3,n1,2):
|
||||
@ -35,4 +36,4 @@ else:
|
||||
break
|
||||
elif(isprime(i)):
|
||||
max=i
|
||||
print max
|
||||
print(max)
|
||||
|
@ -3,6 +3,7 @@ Problem:
|
||||
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
n=int(input())
|
||||
prime=1
|
||||
i=2
|
||||
@ -13,4 +14,4 @@ while(i*i<=n):
|
||||
i+=1
|
||||
if(n>1):
|
||||
prime=n
|
||||
print prime
|
||||
print(prime)
|
||||
|
Reference in New Issue
Block a user