Fibonacci

public struct Fibonacci : IteratorProtocol, Sequence

An Iterator for the Fibonacci sequence

In mathematics, the Fibonacci numbers, commonly denoted Fn form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.

Since the sequence is infinite, the iterator will always return a BigInt.

  • Creates a Fibonacci IteratorProtocol / Sequence

    Declaration

    Swift

    public init()
  • Return the current number in the Fibonacci sequence. It gives F_n=F_n-1 + F_n-2

    Declaration

    Swift

    mutating public mutating func next() -> BigInt?
  • Makes Fibonacci conforming to the Sequence protocol

    Declaration

    Swift

    public func makeIterator() -> Fibonacci