-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 33
More file actions
39 lines (28 loc) · 1.28 KB
/
Copy pathproblem 33
File metadata and controls
39 lines (28 loc) · 1.28 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
"""
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
"""
def same_digit(numerator, denominator):
divisor = numerator / denominator
first = denominator % 10
second = (denominator % 100 - first) / 10
first_numerator = numerator % 10
second_numerator = (numerator % 100 - first_numerator) / 10
if first == second_numerator:
solution = (numerator % 10) / (denominator // 10)
if solution == divisor and solution < 1:
print(solution)
if second == first_numerator:
solution = (numerator // 10) / (denominator % 10)
if solution == divisor and solution < 1:
print(numerator, denominator, solution)
def main():
for i in range(10, 100):
for j in range(i + 1, 100):
if i % 10 == 0 or j % 10 == 0:
continue
else:
same_digit(i, j)
main()