![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ProjectRuler
Eric505124021
这个作者很懒,什么都没留下…
展开
-
ProjectRuler-1
#If we list all the natural numbers below 10 #that are multiples of 3 or 5, we get 3, 5, 6 and 9.#The sum of these multiples is 23.#Find the sum of all the multiples of 3 or 5 below 1000. def sum原创 2011-11-04 12:38:21 · 452 阅读 · 0 评论 -
ProjectRuler-7
#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?#answer : 104743#require "mathn"def order_of_prime number原创 2011-11-04 12:43:29 · 400 阅读 · 0 评论 -
ProjectRuler-5
#2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.#What is the smallest positive number that is evenly divisible by all of the numbers from 1原创 2011-11-04 12:41:54 · 463 阅读 · 0 评论 -
ProjectRuler-4
#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原创 2011-11-04 12:41:12 · 396 阅读 · 0 评论 -
ProjectRuler-2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...# By considering原创 2011-11-04 12:39:11 · 472 阅读 · 0 评论 -
修改目录文件名-Ruby实现
require 'pathname'def change_name puts "------------" current_path = Pathname.new(File.dirname(__FILE__)).realpath current_file_name = __FILE__ begin Dir::foreach(current_path) do |file|原创 2011-11-04 12:47:03 · 2238 阅读 · 0 评论 -
ProjectRuler-10
#The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.#Find the sum of all the primes below two million.#require 'mathn'def sum_of_primes_below_two_million gen = Prime.new sum = 0 gen.each原创 2011-11-04 12:45:45 · 549 阅读 · 0 评论 -
ProjectRuler-8
#ind the greatest product of five consecutive digits in the 1000-digit number.#73167176531330624919225119674426574742355349194934#96983520312774506326239578318016984801869478851843#8586156078911294原创 2011-11-04 12:44:32 · 480 阅读 · 0 评论 -
ProjectRuler-6
#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 diffe原创 2011-11-04 12:42:40 · 489 阅读 · 0 评论 -
ProjectRuler-3
#The prime factors of 13195 are 5, 7, 13 and 29.#What is the largest prime factor of the number 600851475143 ?require 'mathn'class Integer #这个解法是没有分解number,导致基数太大,效率极低 #def big_prime # lock =原创 2011-11-04 12:40:17 · 551 阅读 · 0 评论 -
ProjectRuler-9
#A Pythagorean triplet is a set of three natural numbers, a b c, for which,#a2 + b2 = c2#For example, 32 + 42 = 9 + 16 = 25 = 52.#There exists exactly one Pythagorean triplet for which a + b + c原创 2011-11-04 12:45:14 · 472 阅读 · 0 评论