]> gitweb.factorcode.org Git - factor.git/blob - extra/project-euler/016/016.factor
Switch to https urls
[factor.git] / extra / project-euler / 016 / 016.factor
1 ! Copyright (c) 2007, 2008 Aaron Schaefer.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: math.functions project-euler.common sequences ;
4 IN: project-euler.016
5
6 ! https://projecteuler.net/index.php?section=problems&id=16
7
8 ! DESCRIPTION
9 ! -----------
10
11 ! 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
12
13 ! What is the sum of the digits of the number 2^1000?
14
15
16 ! SOLUTION
17 ! --------
18
19 : euler016 ( -- answer )
20     2 1000 ^ number>digits sum ;
21
22 ! [ euler016 ] 100 ave-time
23 ! 0 ms ave run time - 0.67 SD (100 trials)
24
25 SOLUTION: euler016