Problem 63

https://projecteuler.net/problem=63

Powerful digit counts

The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.

五位数16807同时是7的五次方,同样地,九位数134217728是8的九次方。

How many n-digit positive integers exist which are also an nth power?

有多少个n位数正整数,这些正整数同时是某个数字的n次方?

from power import power

count = 0
for i in range(1, 100):
for p in range(1, 100):
num = power(i, p)
if len(str(num)) == p:
print(i, p, num)
count += 1
print(count)
# power.py
def power(x, y):
if y == 1:
return x
tot = 1
for i in range(y):
tot *= x
return tot if __name__ == '__main__':
for x in range(1, 5):
for y in range(1, 5):
print('power({0}, {1}) = {2}'.format(x, y, power(x, y)))

最新文章

  1. WPF中Ribbon控件的使用
  2. 解决IE7和IE6不支持javaScript中的indexOf函数的问题
  3. 数据结构和算法 – 8.链表
  4. CE 文件读写操作
  5. UWP开发入门(二十)——键盘弹起时变更界面布局
  6. HDU 3998 Sequence(经典问题,最长上升子序列)
  7. MariaDB 加密特性及使用方法
  8. 技术解析:锁屏绕过,三星Galaxy系列手机也能“被”呼出电话
  9. C++学习笔记之函数指针
  10. 常用的MIME类型(资源的媒体类型)
  11. AngularJs练习Demo14自定义服务
  12. Windows Server时间服务器配置方法
  13. webMagic解析淘宝cookie 提示Invalid cookie header
  14. FCC(ES6写法)Pairwise
  15. 【PAT】B1074 宇宙无敌加法器(20 分)
  16. easyui 日期控件限制起始相差30天
  17. CentOS下利用mysqlbinlog恢复MySQL数据库
  18. C语言学习笔记 (007) - 数组指针和通过指针引用数组元素的方法总结
  19. openerp用wizard导入excel数据
  20. 服务器搭建2 VSFTP搭建FTP服务器

热门文章

  1. idea2016的使用心得 --- 太棒了
  2. mysql20170410练习代码+笔记
  3. ios11--UIButton
  4. Linux设备驱动模型【转】
  5. Protected vs protected internal (Again) in c#
  6. bzoj1977 [BeiJing2010组队]次小生成树 Tree——严格次小生成树
  7. 【Hibernate总结系列】使用举例
  8. Dsp和ARM的区别
  9. poj1988Cute Stacking
  10. php 获取客户端的真实ip地址 通过第三方网站