Problem 56
2024-08-31 00:37:02
Problem 56
https://projecteuler.net/problem=56
Powerful digit sum
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
一个古戈尔(10100) 数虽然巨大无比,但是它的位数之和仅仅为1。
Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?
考虑以下情况:
ab, a, b < 100,
最大的位数之和为多少?
from power import power maximum = 0
for a in range(1, 100):
for b in range(1, 100):
num = power(a, b)
digits = list(str(num))
digits_sum = 0
for i in digits:
digits_sum += int(i)
if digits_sum > maximum:
maximum = digits_sum
print(maximum)
# 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)))
最新文章
- 完美解决全面屏蔽Google教程(终结者)
- SOA 架构中的ESB是更好的应用于异构系统集成整合还是用于统一服务调用/基础服务实施
- ubuntu 安装fcitx输入法
- 从Jetty、Tomcat和Mina中提炼NIO构架网络服务器的经典模式(一)
- C#并行和多线程编程_(1)认识Parallel
- CSS左侧固定宽 右侧自适应(兼容所有浏览器)
- springBoot系列教程05:fastjson的集成、配置及使用
- IE浏览器getElementsByTagName方法的兼容问题
- erlang二进制
- centos修改主机名 root@后面的名字
- ul li 的 float:left;
- Codeforces Round#416 Div.2
- iOS: Designated Initializer(指定初始化函数)
- 【已解决】mac上appium报错:“Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path”
- 020.Zabbix的Actions配置
- ExecutorService中submit和execute的区别<;转>;
- C#怎样用文件读写在文件的原有基础上追加一行数据
- AtCoder Grand Contest 019 F-yes or no
- 深入理解javascript函数系列第三篇
- 说说JDK中的List-ArrayList、Vector、LinkedList
热门文章
- vijos - P1302连续自然数和 (公式推导 + python)
- pygame save that Stream as video output.
- springmvc的执行流程详解
- JavaScript Patterns 2.5 (Not) Augmenting Build-in Prototypes
- 选择排序(1)——简单选择排序(selection sort)
- [POI 2018] Prawnicy
- MySQL 字符编码问题详细解释
- Coursera Algorithms week3 快速排序 练习测验: Decimal dominants(寻找出现次数大于n/10的元素)
- Hyper-v 3.0 安装centos6.3
- 解决macOS升级之后每次使用ssh都要输入密码的问题