Project Euler Problem 33

Problem 33

Digit cancelling fractions

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.

49/98是一个有趣的分数,因为缺乏经验的数学家可能在约简时错误地认为,等式49/98 = 4/8之所以成立,是因为在分数线上下同时抹除了9的缘故。

我们也会想到,存在诸如30/50 = 3/5这样的平凡解。


# 思路:两个数组成的分数可以写作ij/jk=i/k   ij/ki=j/k
for i in range(1,10):
    for j in range(1,10):
        for k in range(1,10):
            if (10*i+k)*j == (10*k+j)*i and i != k:
                print([10*i+k, 10*k+j])

文章标签: Project Euler
个人分类: Project Euler
上一篇Project Euler Problem 32
下一篇Project Euler Problem 34
想对作者说点什么? 我来说一句