Project Euler Problem 56: Powerful digit sum【暴力】

PE其他解题报告请参考这里,本题答案在留言首条

Powerful digit sum

Problem 56

A googol ( 1 0 100 10^{100} 10100) is a massive number: one followed by one-hundred zeros; 10 0 100 100^{100} 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.

Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?


题意:

让你求在范围内,最大的数位和

分析:

参考代码
def f(a, b):
    c = pow(a, b)
    sum = 0
    for i in range(len(str(c))):
        sum += int(str(c)[i])
    return sum
res = -1
for i in range(100):
    for j in range(100):
        res = max(res, f(i, j))
print(res)

阅读好习惯:点赞 + 收藏~

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值