[Math] Count number of values between two numbers

arithmetic

I am finding with some formulas for my web application. I need a formula that counts the number of values between two number, e.g. there are four numbers (3,4,5,6) between 2 and 7

Best Answer

larger - smaller - 1. If you don't count the larger and the smaller (like your example).

If the numbers are $n, n+1, \dots, n+k , n+k+1$, the numbers you want are $n+1, n+2, \dots, n+k$, which are $k$ in number = $n+k+1 - n - 1$ = larger - smaller - 1.