#!/usr/local/bin/ruby # http://d.hatena.ne.jp/takatoh/20090207/fizzbuzz fizzbuzz = Fiber.new do fizz = ["", "", "Fizz"].cycle buzz = ["", "", "", "", "Buzz"].cycle n = 1 while s = fizz.next + buzz.next Fiber.yield(s == "" ? n.to_s : s) n += 1 end