Chapter 23. The Fibonacci Sequence

 

If liberty means anything at all, it means the right to tell people what they do not want to hear.

 
 --George Orwell
 

Subtlety chases the obvious in a never-ending spiral and never quite catches it.

 
 --Nero Wolfe

Introduction

Those who enjoy mathematical elegance may share my appreciation of the Fibonacci sequence and its associated relationship, the Golden Ratio. In this chapter we’re going to look at how we might represent this mathematical sequence as a collection, in the form of an STL sequence class, and then consider whether it might be better represented as an iterator, before finally coming back to seeing how a range-limited sequence is the most discoverable representation.

Unlike the other STL extensions ...

Get Extended STL, Volume 1: Collections and Iterators now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.