/extra/project-euler/016/016.factor

http://github.com/abeaumont/factor · Factor · 25 lines · 5 code · 9 blank · 11 comment · 0 complexity · 771e47a09297167df4840164ac7d1702 MD5 · raw file

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