# Substitution rules not working

I have this summation, $$S$$,...

\begin{alignat}{2}% & P(0) = (1 - A) \notag \\ & P(1) = (1 - A)(e^A - 1) \\ & P(i + 1) = \frac{1}{P(0,A)}\Bigl\{P(i) - [P(0) + P(1)] P(i,A) \\ & \quad \quad-\sum_{\nu=2}^{i} P(\nu) \cdot P(i - \nu + 1, A) \Bigr\}. \label{md1ssprob} \end{alignat}

$$S = \sum _{k=0}^{\infty } \left(1-\sum _{i=r+1}^{2 r+1} \binom{2 r+1}{i} \left(1-\frac{P(k,\lambda )}{\sum _{j=0}^k P(j,\lambda )}\right)^i \left(1-\left(1-\frac{P(k,\lambda )}{\sum _{j=0}^k P(j,\lambda )}\right)\right)^{2r+1-i }\right)$$

and I want to be able to substitute for some arbitrary value $$r$$, but it doesn't seem to want to work. It only works when I manually enter the values for the summation.

Here is the code I have (that works if I manually put in the $$r$$ value).

Pn[0, \[Lambda]_] := 1 - \[Lambda];
Pn = (1 - \[Lambda])*(E^\[Lambda] - 1);
Pn[n_, \[Lambda]_] := (1 - \[Lambda])*
Sum[E^(j*\[Lambda])*(-1)^(n -
j)*(((j*\[Lambda] + n - j)*(j*\[Lambda])^(n - j - 1))/(n -
j)!), {j, 0, n}];
Sum[1 - Sum[
Binomial[2*r + 1,
i]*(1 - Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}])^
i*(1 - (1 -
Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}]))^(2*r +
1 - i),
{i, r + 1, 2*r + 1}], {k, 0, 35}] /. {\[Lambda] ->
0.5, r -> 101}



Why does it do this? Why can't I just substitute some $$r$$ value using the $$\longrightarrow$$ rule?

Also, in the code I only sum to 35. The reason is that if I put the symbol $$\infty$$ in, it takes forever and never completes. Also, it overflows sometimes if the number is too high. If you have any thoughts on that as well, it would be appreciated.

Maybe like this:

 ClearAll["*"]; Remove["*"];(* Clears All*)

Pn[0, \[Lambda]_] := 1 - \[Lambda];
Pn[1, \[Lambda]_] := (1 - \[Lambda])*(E^\[Lambda] - 1);
Pn[n_, \[Lambda]_] := (1 - \[Lambda])*Sum[E^(j*\[Lambda])*(-1)^(n - j)*(((j*\[Lambda] + n - j)*(j*\[Lambda])^(n - j - 1))/(n - j)!), {j, 0, n}];

f[\[Lambda]_, r_] := Sum[1 - Sum[Binomial[2*r + 1, i]*(1 - Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}])^i*(1 - (1 - Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}]))^(2*r + 1 - i), {i, r + 1, 2*r + 1}], {k, 0, 35}]

N[f[1/2, 101], 50]
(* 1.0010532880860907539154104616060531372235322012173 *)

f[1/2, 101] (*Large expression ! *)


For k->Infinity I doubt there's a closed form for the Sum.