code: public function sum($n, $m = 0)
    {
      if($m > 0)
        return $this->sum($n+$m) - $this->sum($m);
  
      static::ensureValid($n);
  
      return $this->b * (1 - pow($this->q, $n)) / (1 - $this->q);
    }
docs: Calculate sum of N consequent characters.
  
  Either N first, or N after first M.
  
  @param int $n number of elements to sum up
  @param ?int $m number of elements to skip
  @return float the sum of elements