欧拉计划33题

/**
*
* Digit cancelling fractions
* Problem 33
*
* 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.
*
* @author dcb
*
*/
找出有奇特约分性质的数如49/98 = 4/8

分析:
此题求解:AB/BC = A/C为真分数
说明:B>A,且C>A
使用三层嵌套循环很容易球得解

代码实现:
for (int i = 1; i <= 9; i++){
for (int j = i + 1; j <= 9; j++){
for (int k = i + 1; k <= 9; k++){
int a = i * 10 + j;
int b = j * 10 + k;
if (a * k == b * i){
System.out.println("" + a + "/" + b);
dividend *= i;
divisor *= k;
}
}
}
}


结果100
16/64
19/95
26/65
49/98
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值