✨ feat(eular_12.py):优化质数测试参数并修复组合数计算逻辑
✨ feat(eular_13.py):新增超大整数加法解决方案 📝 docs(eular_13.md):添加算法说明文档 ✨ feat(eular_14.py):新增Collatz序列最长链计算 📝 docs(eular_14.md):添加性能优化说明 ✨ feat(eular_15.py):新增网格路径组合数学解法 📝 docs(eular_15.md):添加组合数学详细说明 ✨ feat(eular_16.py):新增幂数字和计算功能 ✨ feat(eular_16.hs):新增Haskell版本实现
This commit is contained in:
17
solutions/0016.PowerDigitSum/eular_16.py
Normal file
17
solutions/0016.PowerDigitSum/eular_16.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
|
||||
|
||||
What is the sum of the digits of the number 2^1000 ?
|
||||
"""
|
||||
|
||||
|
||||
def power_digit_sum(n):
|
||||
return sum(int(digit) for digit in str(2**n))
|
||||
|
||||
|
||||
def main():
|
||||
print(power_digit_sum(1000))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user