You are viewing a single comment's thread. Return to all comments →
import math import os import random import re import sys
def p_fact(n): f=[] i=2 while i*i <=n: if n%i==0: f.append(i) n//=i else: i+=1 if n>1: f.append(n) return max(f)
if name == 'main': t = int(input().strip())
for t_itr in range(t): n = int(input().strip()) print(p_fact(n))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #3: Largest prime factor
You are viewing a single comment's thread. Return to all comments →
!/bin/python3
import math import os import random import re import sys
def p_fact(n): f=[] i=2 while i*i <=n: if n%i==0: f.append(i) n//=i else: i+=1 if n>1: f.append(n) return max(f)
if name == 'main': t = int(input().strip())