5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

今週のアルゴリズム:フィボナッチ数列

Last updated at Posted at 2013-12-04

CodeIQ Advent Calendar http://www.adventar.org/calendars/82

Enumeratorの使い方の好例だと思います.

#!/usr/bin/ruby
puts Enumerator.new{|y|
	a=b=1
	loop{
		a,b=a+b,a
		y<<a if a%a.to_s.chars.map(&:to_i).reduce(:+)==0
	}
}.take(11)*',' # 2,3,5,8,21,144,2584,14930352,86267571272,498454011879264,160500643816367088

…後ほど解説記事出ますよね?

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?