matlab 欧拉计划 33

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.

思路

(我感觉这个问题不太好理解,于是查了一些资料,然后理出一种思路。 感谢各位大佬分享经验。)

  1. 要求:找出四个非平凡数,找出它们最大公因数最简化后(也就是相乘得到的最简分数形式)的分母。
  2. 经观察可得,这种非平凡数要求分子个位数与分母十位数相同,同时将对应位的数字略去后得到的分数与原分数结果相同。(我觉得很神奇)

程序

clc;clear all;
format rat;
t=[];t1=1;
for i=10:99
    for j=10:99
        ii=num2str(i);        i1=str2num(ii(1));   i2=str2num(ii(2));
        jj=num2str(j);        j2=str2num(jj(2));   j1=str2num(jj(1));
       if i2==j1
        if (i/j)==(i1/j2)&&(i/j)<1
            t=[t ;i j];t1=t1*(i/j);
        end
       end
    end
end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值