How many natural numbers less than one million have the sum of their digits equal to 12?
6062
The smallest is 39 and the largest is 930000.
---------
sols = []
ct = 0
for n in range(1000001):
if sod(n) == 12:
ct += 1
sols.append(n)
print(ct)
print(sols[0], sols[-1])
|
Posted by Larry
on 2024-06-20 07:54:38 |