2008-10-17 黄金比 javascript var [a, b] = (function fib(a, b) b < 10000000000000000 ? fib (b, a + b) : [a, b] )(1, 1); alert(b / a); // 1.6180339887498947 Rubyだとこんな感じかなあ def sum(a) a.inject(0) {|sum, n| sum + n} end fib = (1..1000).inject([1, 1]) {|a, b| a.push(sum(a.last 2))} fib[-1].to_f / fib[-2]