until yield statement indicates the next value at that pointthe procedure is temporarily interruptedonly to be resumed when another value is requested when the flow of control naturally reaches the end of our procedure (or zero-argument return statement) stopiteration exception is automatically raised although this particular example uses single yield statement in the source codea generator can rely on multiple yield statements in different constructswith the generated series determined by the natural flow of control for examplewe can greatly improve the efficiency of our generator for computing factors of numbernby only testing values up to the square root of that numberwhile reporting the factor // that is associated with each (unless // equals kwe might implement such generator as followsdef factors( ) = while nif = yield yield / + if =nyield generator that computes factors while sqrt(nspecial case if is perfect square we should note that this generator differs from our first version in that the factors are not generated in strictly increasing order for examplefactors( generates the series in closingwe wish to emphasize the benefits of lazy evaluation when using generator rather than traditional function the results are only computed if requestedand the entire series need not reside in memory at one time in facta generator can effectively produce an infinite series of values as an examplethe fibonacci numbers form classic mathematical sequencestarting with value then value and then each subsequent value being the sum of the two preceding values hencethe fibonacci series begins as the following generator produces this infinite series def fibonacci) = = while trueyield future = future keep going report valueaduring this pass this will be next value reported and subsequently this