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

Project Eueler: problem7

問題 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number? 回答 prime = [2] flg = 0 (3..9999999).each do |n| flg = 0 prime.each do |p| if n % p == 0 flg = 1 br…

Project Eueler: problem6

問題 The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the…

Project Euler : problem4

問題 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.Find the largest palindrome made from the product of two 3-digit numbers. 回答 res = 0 t = 0 (1..999).e…