- 积分
- 46
- 注册时间
- 2007-4-28
- 仿真币
-
- 最后登录
- 1970-1-1
|
来自:http://forum.simwe.com/viewthread.php?tid=911288&extra=page%3D1%26amp%3Bfilter%3Dtype%26amp%3Btypeid%3D508
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
It can be seen that the 12^(th) digit of the fractional part is 1.
If d_(n) represents the n^(th) digit of the fractional part, find the value of the following expression.
d_(1) × d_(10) × d_(100) × d_(1000) × d_(10000) × d_(100000) × d_(1000000
把数字从1开始按从小到大的顺序排成一列,求出其中第1,10,100,1000,10000,100000,1000000位(从左算起)之积。
我用下面的办法实现,但是觉得有点投机取巧的感觉,希望大家一起讨论,找出高效的做法
- clear;clc;close all
- tic
- a=1:10^6;
- b=int2str(a);
- b(b==' ')=[];
- c=prod(str2double({b(1),b(10),b(100),b(1000),b(10000),b(100000),b(1000000)}));
- toc
复制代码- Elapsed time is 3.192799 seconds.
- >> c
- c =
- 210
-
复制代码 |
|