# how many ways we can choose 3 and more consecutive number from set of N numbers [duplicate]

Suppose we have a set like (1,2,3) then there is only one way to choose 3 consecutive number...its (1,2,3)....for a sets of 4 (1,2,3,4) we have 3 ways ( (1,2,3), (2,3,4), (1,2,3,4)) for five its 8 ,for 6 its 20, for 7 its 47 and so on....So for a given N, I can get the answer by applying brute force, and calculating all such subset having 3 or more consecutive number. Here I am just trying to find out a pattern, a technique to get the number of all such subset for a given N. The problem is further generalized to .....discover m consecutive number within a set of size N.

-

## marked as duplicate by Marc van Leeuwen, William, tomasz, J. M. is back., NorbertOct 3 '12 at 20:08

Are you sure it's $20$ for $n=5$? I think it should be $6$. – VelvetThunder Sep 7 '12 at 4:58
$\frac{1}{2} \left(N^2-3 N+2\right)$ – VelvetThunder Sep 7 '12 at 5:02
Do all of the numbers in the subset have to be consecutive, or does the subset just have to contain at least three consecutive numbers? In other words, is $\{1,2,3,5\}$ acceptable? If all of them have to be consecutive, see the hints below; if not, see this answer. In either case the number for $5$ is not $20$; it’s either $6$ or $8$. – Brian M. Scott Sep 7 '12 at 5:04
srry for confusion its 8 for 5 and so on(typo mistkae), I have updated the question – rspr Sep 7 '12 at 6:09
for 5 the 8's are as...(3,4,5), (2,3,4), (1,2,3,4), (1,3,4,5), (1,2,3), (1,2,3,5), (1,2,3,4), (1,2,3,4,5) – rspr Sep 7 '12 at 6:14

The number of selections of $k$ consecutive things out of $n$ things in a row is given by $n-k+1$.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}