Project Euler : Problem 016

Project Euler problems in Oforth . Feel free to post your own code.

Project Euler : Problem 016

Postby Franck » 01 Aug 2015 17:18

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?

Code: Select all
: sumDigits(n) { 0 while(n) [ n 10 /mod ->n + ] }

2 1000 pow sumDigits
Franck
 
Posts: 144
Joined: 29 Oct 2014 19:01

Return to Project Euler in Oforth

Who is online

Users browsing this forum: No registered users and 1 guest