How to: create a sequence of fibonacci numbers

You can create sequences from everything using the FunctionBasedSequence class. You only need a method that matches to the Func<Integer, T> delegate.

This code sample enumerates the first n fibonacci numbers:
foreach (
    Integer i in new FunctionBasedSequence<Integer>() {
        Function = NumberTheory.FibonnaciNumber

Last edited May 10, 2010 at 2:08 PM by BlueCode, version 1


No comments yet.