Skip to content

Commit eca9ddc

Browse files
amarjeet045yshshrm
authored andcommitted
Create prime_factor.py
1 parent 5640eb2 commit eca9ddc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: prime_factor.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#this is a program to find the largest prime factor of a number
2+
#here t is the test case and n is the number of input
3+
t = int(input())
4+
while(t):
5+
t-=1
6+
n = int(input())
7+
i=2
8+
while (i*i<=n):
9+
if(n%i==0):
10+
n = int(n/i)
11+
i+=1
12+
if(n>2):
13+
i=n
14+
print(i)
15+
16+

0 commit comments

Comments
 (0)