Hi Milagros,

Soroban has given you an excellent solution already, but here is a generating function approach since that seems to be what you are looking for.

First, let

= the number of ways to form a binary string of length 50 with exactly r ones, and let

.

We know

,

so by the binomial theorem,

.

Now let

= the number of ways to form a binary string of length 50 with exactly r ones, all at the end. There is only one such string, so

and

Now the number of ways to form a binary string of length 50 and another string of length 50 with all the one's at the end, containing a total of r ones, is

which has the generating function

.

So the answer to the original question is the coefficient of

in

which I think probably reduces, in the end, to the same answer given by Soroban (but I haven't checked it).