EularProject 40: 计算正整数连接构成无理数的确定位
2015-07-18 01:32
218 查看
Champernowne’s constant
Problem 40
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021…
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
Answer:
210
Completed on Fri, 17 Jul 2015, 18:25
Go to the thread for problem 40 in the forum.
python code:
Problem 40
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021…
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
Answer:
210
Completed on Fri, 17 Jul 2015, 18:25
Go to the thread for problem 40 in the forum.
python code:
__author__ = 'zhengyi' def funcNum(x): k=0 while x>0: k+=1 x=x//10 return k def func(d,c,k): temp=funcNum(c) for i in range(0,d-k): c=c//10 return c%10 c=1 d=1 r=1 index=[pow(10,i) for i in range(1,7)] while len(index)>0: c+=1 d+=funcNum(c) if d==index[0]: r*=c%10 del index[0] continue else: if d>index[0]: r=r*func(d,c,index[0]) del index[0] print(r)
相关文章推荐
- Gradle tip #3-Task顺序
- 随笔(一)
- 黑马程序员——泛型(Generic)的理解和使用
- redis学习-事物,生存时间
- 什么是面向对象编程--Quora上被Vote7.3K的回答(来自Steve Jobs)
- 黑马程序员----java中的多态
- 你所熟知的 LRU(最近最少使用)
- STM32中的(bit-band)
- 简单计时器
- 控制台相关语法
- 在MacBook上查看Java的安装路径并设置JAVA_HOME变量
- python深拷贝与浅拷贝
- Struts2数据传输的背后机制:ValueStack(值栈)
- cc美团 滑动删除(SwipeListView)
- poj 2942 Knights of the Round Table(无向图的双连通分量+二分图判定)
- Linux环境下stl库使用(vector)
- DNS子域授权、view配置详解
- 转发一位学员一次性过高项的感言
- openerp学习笔记 对象间关系【多对一(一对一)、一对多(主细结构)、多对多关系、自关联关系(树状结构)】
- C++ 全局变量 局部变量 静态变量 及 extern