Problem 2 by Bayes rule.
N is a random variable (RV) of number of filled envelopes.
C is a RV of selected envelope contains coin. P(C) means P(C=true) when appropriate.
Prior distribution
P(N=n) = 1/(m+1)
by the problem setup
P(C|N=n) = n/m
by the rule of total probability
P(C)=sum_n P(C|N=n)P(N=n) = sum_n (n/m/(m+1))=m(m+1)/2/m/(m+1)=1/2
by Bayes rule
P(N=n|C) = P(C|N=n)P(N=n)/P(C) = 2n/m/(m+1)
Let C' is a RV of picking filled envelope second time.
by the problem statement
P(C'|N=n,C) = (n-1)/m
by the rule of total probability
P(C'|C)=sum_n P(C'|N=n,C)P(N=n|C) = ... substitutions and simplifications ... = 2(m-1)/(3m)
solving P(C'|C)=P(C) obtains
m=4
This went over well in the xkcd logic puzzle forum (my hand was not removed), so I thought I'd try it here. It came to me in a dream, so by solving it you may be helping to summon an elder god or something.
Bob replies, "That depends on what random function you used to choose how many envelopes to fill. If you, say, flipped m coins and put each one that came up heads in an envelope, the expected value is $.50."
Alice explains what her random function was, and Bob calculates the expected value. For kicks, he pays her that amount, and she lets him pick a random envelope. It has a coin in it! Bob pockets the coin. Alice then takes the now-empty envelope back, and shuffles it into the others. "Congratulations," she says. "So, what's the expected value of playing the game again, now that there's one fewer coin?"
"Same as before," Bob replies.
Problem 1: Give a value for m and a random function for which this makes sense (there are many).