There are $40$ letters and $40$ envelopes with addresses. The letters are put in envelopes at random. What is the expected number of letters in their corresponding (correct) envelopes ?
One envelope can hold only one letter.
I start with $E(X_i)=1\cdot\dfrac{1}{40}+0\cdot\dfrac{39}{40}=\dfrac{1}{40}$.
$X_i$ being the $i^{th}$ letter placed correctly or not ($1$, if correctly placed and $0$, if not). I need to calculate the expected count of letters assigned correctly.
Then add up all $\implies$ $E(X_1+X_2+\ldots+X_{40})=\underbrace{\dfrac{1}{40}+\dfrac{1}{40}+\ldots+\dfrac{1}{40}}_{40\text{ times}}=1$
Now my doubt is that if I put $39$ letters correctly, the $40^{th}$ one will be automatically assigned correctly . So should I add only $39$ times ?
Any other mistakes I may be doing here ? Please advise.
The number of envelopes that go to the correct place is $$X_1+\cdots+X_{40}$$ The expected value is $$E[X_1+\cdots+X_{40}]=1$$ as you have computed. The fact that the $X_i$ depend on each other is irrelevant as expectation is linear.