apollonin/numphp

View on GitHub
src/Generator/Fibonacci.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace numphp\Generator;

class Fibonacci
{
    public static function generate()
    {
        $curr = 1;
        $prev = 0;

        while(true)
        {
            yield $curr;

            $next = $curr + $prev;
            $prev = $curr;
            $curr = $next;
        }
    }
}