Find sum of the digits of: 2023
2023
For example, the sum of digits of 216= 65536 is 6+5+5+3+6 =25
First, find the digital root.
The digital root of 2023 is 7
The digital root of a base to a power follows a pattern.
When the base has a digital root of 7, the pattern had a cycle length of 3 and is {7,4,1,7,4,1, ...}
The exponent 2023 is 1 mod 3.
So the digital root of 2023^2023 is the same as the digital root of 7**1
The digital root of 2023^2023 is 7.
I searched for a pattern in sum of digits of powers of 2023 but without success.
So I was unable to find a clever solution, although by direct calculation the answer is
30112.
sod(2023**2023)
Out[2]: 30112
--------
def sod(n):
""" Input an integer. Returns the Sum of the Digits """
aList = list(str(n))
ans = 0
for c in aList:
ans = ans + int(c)
return ans
|
Posted by Larry
on 2023-10-27 12:42:51 |