Home Project Euler Teaching Projects Gallery

Problem 15: Lattice paths

215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 21000?


Algorthim:

There's not real algorthim here besides, first finding the number of digits the number contains. Then, allocating each digit into an array. Then summing the array up. Surprisingly this seems to work pretty well. 21000 is quite a number...

Code:

Result:

Answer: 1366
Runtime: 1.3 ms