2011-07-31から1日間の記事一覧

Project Eueler: problem16

問題 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? 回答 def calc(num) 2**num end def do_sum(num) sum = 0 str = num.to_s 0.upto(str.size.to_i-1) do |n| sum += str[n,1].to_…

Project Eueler: problem17

問題 If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many le…