**Variable:** A temporary variable "temp" is used to store the previous value for later use.

**Range:** We use range() to loop over the entire numeric range to the desired Fibonacci number.

**Note:** We do not need recursion for a Fibonacci sequence. Iteration, with a temporary variable, works as well—and is likely faster.

**Tip:** Using lookup tables or "memoizing" math computations is usually faster for nontrivial requirements.

**List:** To access small Fibonacci numbers quickly, store them in a list and just reuse that list when required.

**Zero:** Fibonacci himself did not include the 0, but modern scientists do. It is best to side with modernity.

**Tip:** I recommend checking as many sources as possible when researching. This includes websites other than this one.

**But:** Don't spend the whole day browsing Wikipedia if you are doing something important.

**Quote:** Fibonacci began the sequence not with 0, 1, 1, 2, as modern mathematicians do but with 1, 1, 2.

Home

Dot Net Perls

© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.