$n) { return 0; } // $k and $n - $k will always produce the same value, so use smaller of the two $k = min($k, $n - $k); return $this->calculate($n, $k); } abstract protected function calculate(int $n, int $k): float; }