-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prime_Factorisation_of_a_Number.py
36 lines (36 loc) · 1.16 KB
/
Prime_Factorisation_of_a_Number.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Program to find the prime factorisation of a number
def prime_factorisation_indv_prog_one():
n=input('Enter a number of which you want to find the prime factors')
N=int(n)
print('The prime factorisation of the number')
for a in range(2,(N//2)+1):
if N%a==0:
lst=list()
result=True
while result:
p=N
for i in range(2,int(p//2)+1):
if p%i==0:
break
lst.append(i)
N=N/i
i=2
if N!=2:
for x in range(2,((int(N)//2)+1)):
if int(N)%x==0:
result=True
break
else:
result=False
if N!=1:
lst.append(int(N))
else:
result=False
break
else:
result=True
print(int(n),'=',end=' ')
print(*lst,sep=' × ')
break
else:
print(int(n),'=',1,'×',N)