public static function geometricProgression(int $n, $a, $r) : array { if ($r === 0) { throw new Exception\BadParameterException('Common ratio r cannot be 0'); } $progression = []; if ($n < 0) { return $progression; } for ($i = 0; $i < $n; $i++) { $progression[] = $a * $r ** $i; } return $progression; }