Expected value of a random variable Max 
You choose a uniformly random element, $a$, from $\{1, 2, . . . , 100\}$, and you choose
  a uniformly random element, $b$, from the same set $\{1, 2, . . . , 100\}$. ($a$ and $b$ are chosen
  independently)  
Define the random variable X to be $X = max(a, b)$, where $X$ is the maximum of $a$ and $b$.  

The answer is: 

$\mathbb{E}(X) = \sum_{k=1}^{100} k \cdot \frac{1+2(k-1)}{100^2}$

I know that the formula for the expected value is $\mathbb{E}(X) = \sum_{}^{} k \cdot Pr(X = k)$.  
I understand that the sample space is $100^2$, however I do not understand the numerator $1+2(k-1)$. 
Thank you.
 A: When $ X = k $, we have $ 3 $ possibilities. We can have $ a < b $ and $ b = k $, we can have $ a > b $ and $ a = k $, and we can have $ a = b = k $. There are $ k - 1 $ ways in which each of the first two scenarios can happen, since, in the first case for instance, we can have $ a = 1, ..., k - 1 $. This gives us $ 2(k-1) + 1 $ distinct possibilities overall. 
A: $X=k$  for all the cases $a = k$ and $b$ is chosen from $\{1,\dots, k-1\}$ so $k-1$ cases.
Same for $b=k$ so $k-1$ more cases.
Plus the case $a = k$ and $b=k$.
$2(k-1) +1$ favorable cases
A: Have a look at what $Pr(X=k)$ is, $X=k$ if:


*

*$a=b=k$ (which happens with probability $\frac{1}{100^2}$)

*$a=k$ (probability $\frac{1}{100}$), $b<k$ ($k-1$ possibilities so probability $\frac{k-1}{100}$), in the end that has a probability of $\frac{k-1}{100^2}$

*$b=k$ (probability $\frac{1}{100}$), $a<k$ ($k-1$ possibilities so probability $\frac{k-1}{100}$), in the end that has a probability of $\frac{k-1}{100^2}$


In the end, the total probability is the sum of the probabilities of those three cases.
