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