Distribution of N balls numbered 1 to N with replacement An urn contains N balls numbered 1.2.3...N.
I draw at random n balls, one by one with replacement.
Let X the smallest number, the largest Y and S the sum of all the n numbers
How to compute:
-the probability P(X=x,Y=y)  that X=x AND Y=y 
-the probability that S=s 

You should count the number of the "good" instances and divide by the total number of instances.
For the first question - if the smallest is $x$ and the largest is $y$, then you are writing words of length $n$ using only the symbols $x,x+1,...,y-1,y$ (why?). How many such words do you have?
For the second question - it's equivalent to counting the number of solutions to $X_1+...+X_n=s$ where $1\leq X_i\leq N$, and then dividing by the total number of words of length $n$ over $1,...,N$ (why?). As to finding the number of solutions to this equation: it's the same as the number of solutions to $Y_1+...+Y_n=s-n$ where $0\leq X_i\leq N-1$. This can be done with exclusion-inclusion principle.
The other question, in your second post, is very similar. You can use the same approach, but there each letter/value can appear only once.
