#ifndef FIB_COLLJGBP #define FIB_COLLJGBP // fibonacci sequence. // 0,1,1,2,3,5,8,13,21,34,... class FibSeq { public: typedef uint64_t int_type; FibSeq(int_type limit) : m_limit(limit), m_cur(0), m_next(1) {} void Reset() { m_cur = 0; m_next = 1; } void ResetLimit(const int_type v) { m_limit = v; Reset(); } int_type Limit() const { return m_limit; } int_type Cur() const { return m_cur; } int_type Inc() { if (m_next < m_limit) { m_next = m_next + m_cur; m_cur = m_next - m_cur; } else { m_cur = m_limit; } return Cur(); } private: int_type m_limit; int_type m_cur; int_type m_next; }; #endif // end of include guard: FIB_COLLJGBP