PamGau
Web周り、サッカーの話、ときどきヌコ

RubyでProject Euler - Problem 12

Problem 12 (Project Euler) [和訳])

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...

Let us list the factors of the first seven triangle numbers:

1: 1

3: 1,3

6: 1,2,3,6

10: 1,2,5,10

15: 1,3,5,15

21: 1,3,7,21

28: 1,2,4,7,14,28

We can see that 28 is the first triangle number to have over five divisors.

What is the value of the first triangle number to have over five hundred divisors?

上の2点から素因数分解するメソッドを書けば、あとはなんとでもなりそうです。

素数リストを生成するルーチンも含めて50行ぐらいになり、数秒で答えは出ました。


"RubyでProject Euler - Problem 11" « Home » "RubyでProject Euler - Problem 13"

TrackBack

ご注意
当分の間、トラックバックの受信を行わないことといたしました。過去に戴いたトラックバックのリストについてはそのまま保持いたします。
トラックバックはありません

Comments

コメントはありません。
ご注意
当分の間、JavaScript が有効でないとコメント投稿できないようにします。スパム対策であって、投稿される方の個人情報を取得する目的ではありません。悪しからずご了承ください。
Recent Entries
京都御苑の「自転車道」
Googleの左サイドバーを消すユーザスタイルシート for Firefox , Opera
"Ruby Way"章頭の言葉
"The worst feelings in life"より
裸の英会話
RubyでProject Euler - Problem 59
RubyでProject Euler - Problem 58
RubyでProject Euler - Problem 57
RubyでProject Euler - Problem 55, 56
RubyでProject Euler - Problem 54
Links
PamGau 系
PamGau::Memo
PamGau::Dust
PamgauSigh Wiki
はてなブックマーク
パンパでガウチョ
kyorecobaのdel.icio.us
BLOGNAVI
XREA.COM
VALUE-DOMAIN
PHP ver 4.4.2
Powered by Nucleus CMS Creative Commons
feedberner banner この日記のはてなブックマーク数
BlogPeople
あわせて読みたい