How do you find the number of unique integer sequences of a nondecreasing sequences length $n$ with these conditions?
$$ a_{n+1} \geq a_{n}$$
Possible rephrasing: Given a particular nondecreasing sequence of length $n$ $\{a_1,a_2, \ldots,a_n\}$, how many nondecreasing sequences $\{b_1,b_2, \ldots ,b_n\}$ are there in which $b_i \leq a_i$ for $1 \leq i \leq n$?
The sequence is sorted low to high and the next number is same or higher.
[1,2,3,4,5] or [1,1,2,2,5] or [5,5,5,5,5]
The permutations must be lower than the sequence, but same or higher than the number before it.
For [1,2,3,4,5]
there are 42 unique combinations.
1,1,1,1,1
1,1,1,1,2
1,1,2,2,5
1,1,3,4,5
1,2,3,4,5
1,1,3,2,4 - no because 2 is less than 3
1,3,3,4,5 - no because 3 is greater than 2 in 1,*2*,3,4,5
For 5,5,5,5,5
there are 126 unique sequences.
1,1,1,1,1
1,2,3,4,5
5,5,5,5,5
Brute force counting looks like
for a = 1 to 5
for b = a to 5
for c = b to 5
for d = c to 5
for e = d to 5
count++
print a,b,c,d,e
For [5]
the count is 5.
For [1,5] or [1,1,1,1,5]
the count is 5.
For [5 repeating n times]
n count
1 5
2 15
3 35
4 70
5 126
6 210
7 330
8 495
9 715
10 1001
I tried summation of summation of summation. $n(n+1)(n+2)(n+3)/2*3*4$
3 summations counts sequences length 5 and limits are $n,n,n,n,n$. 4 summations counts 6. 5 summations counts 7.
I don’t know how to subtract sequences if the limits are $1,2,3,4,5$.
how do you get $\frac{10!}{5!6!} = 42$ from $1,2,3,4,5$ and $\frac{9!}{4!5!} = 126$ from $5,5,5,5,5$?
10!/5!6!
from 1,2,3,4,5 and9!/4!5!
from 5,5,5,5,5? – Traffic Jun 07 '19 at 09:28