2008-04-07から1日間の記事一覧

Problem 29 - a^b

イマイチ。Problem 29 - PukiWiki 2 ≤ a ≤ 5 と 2 ≤ b ≤ 5について, a^bを全て考えてみよう: * 2^2=4, 2^3=8, 2^4=16, 2^5=32 * 3^2=9, 3^3=27, 3^4=81, 3^5=243 * 4^2=16, 4^3=64, 4^4=256, 4^5=1024 * 5^2=25, 5^3=125, 5^4=625, 5^5=3125これらを小さい順…

Problem 24 - 順列(2)

前回の教訓を元に攻めていく。Problem 24 - PukiWiki 順列とはモノの順番付きの並びのことである. たとえば, 3124は数1, 2, 3, 4の一つの順列である. すべての順列を数の大小でまたは辞書式に並べたものを辞書順と呼ぶ. 0と1と2の順列を辞書順に並べると 012…

Problem 24 - 順列(1)

Vimごと落ちた。失敗。Problem 24 - PukiWiki (define (permutations s) (define (flatmap proc seq) (apply append (map proc seq))) (define (remove-1 item sequence) (cond ((null? sequence) '()) ((equal? (car sequence) item) (cdr sequence)) (else…

Problem 34 - 階乗してもいっしょ

ガリガリいっちゃうよ。Problem 34 - Project Euler 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.Find the sum of all numbers which are equal to the sum of the factorial of their digits.Note: as 1! = 1 and 2! = 2 are not sums …

Problem 36 - 10進数でも2進数でも回文数

また翻訳してみる。Problem 36 - Project Euler The decimal number, 585 = 1001001001_2 (binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Please note that th…