-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
43 lines (38 loc) · 908 Bytes
/
hello.py
File metadata and controls
43 lines (38 loc) · 908 Bytes
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
#!usr/bin/python
class cal(object):
def he(self, ls):
a = ls[0]
b = ls[1]
c = ls[2]
d = ls[3]
if b == 0 or d == 0:
print "NaN"
return 0
else:
num = [a * d + b * c, b * d]
self.yuefen(num)
if(num[0] == 0):
print "0"
return 0
elif num[1] == 1:
print num[0]
return 0
print num[0]
print num[1]
def yuefen(self, lt):
if lt[0] > lt[1]:
h = lt[0]
else:
h = lt[1]
i = 2
while i <= h:
if lt[0] % i == 0 and lt[1] % i == 0:
lt[0] = lt[0] / i
lt[1] = lt[1] / i
self.yuefen(lt)
i = i + 1
return 0
print "enter four number: "
r = input()
begin = cal()
begin.he(r)