**Taking m=2**,

k=0;

for i1 = 1 to n

for i2 =1 to i1

k=k+1

for i=1, k is incrementing 1 time

for i=2, k is incrementing 2 times

for i=3, k is incrementing 3 times

........................................................

for i=n, k is incrementing n times.

Total increment in k = 1+2+3+................+n = n(n+1)/2 = selecting 2 integers with repetition among n integers.

**Taking m=3,**

for i=1, k is incrementing 1 time. (1 times)

for i=2, k is incrementing 3 times. (1+2 times)

for i=3, k is incrementing 5 times. (1+2+3 times)

.........................................................................

for i=n, k is incrementing (1+2+3+....n) times.

Total increment in k = 1 + (1+2) + (1+2+3) + (1+2+3+4) +.............(1+2+3......+n)

= n(n+1)(n+2) / 6 = selecting 3 integers with repetition among n integers.

Similarly, Take m=k, K will be C(n+k-1,k) = selecting m integers with repetition among n integers.