-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathP33_Digit_Cancel.py
More file actions
51 lines (51 loc) · 1.24 KB
/
P33_Digit_Cancel.py
File metadata and controls
51 lines (51 loc) · 1.24 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import math
prod1=1;
prod2=1;
for i in range (1,100):
for j in range (i+1,100):
#print(prod)
n1=i%10;
n2=i//10
d1=j%10
d2=j//10
x=math.gcd(i,j)
a1=i//x;
a2=j//x
if(n1==0 or d1==0 or n2==0 or d2==0):
continue
if(n1==d1):
x=math.gcd(n2,d2)
t1=n2//x
t2=d2//x
if(a1==t1 and a2==t2):
prod1=prod1*a1
prod2=prod2*a2
continue
if(n1==d2):
x=math.gcd(n2,d1)
t1=n2//x
t2=d1//x
if(a1==t1 and a2==t2):
prod1=prod1*a1
prod2=prod2*a2
continue
if(n2==d1):
x=math.gcd(n1,d2)
t1=n1//x
t2=d2//x
if(a1==t1 and a2==t2):
prod1=prod1*a1
prod2=prod2*a2
continue
if(n2==d2):
x=math.gcd(n1,d1)
t1=n1//x
t2=d1//x
if(a1==t1 and a2==t2):
prod1=prod1*a1
prod2=prod2*a2
continue
x=math.gcd(prod1,prod2)
prod1=prod1/x
prod2=prod2/x
print(prod2)