I am look to code a system by where a given number is given by the user and then a script will work out the total number of combinations using that number all the way down to one.
so if the number was 10 it would need to find all the combinatins of ten numbers, nine numbers, 8 numbers and so on down to one!
So say if the number is 3
then you have
- 3 number combinations (1,2,3) => 1
- 2 number combinations (1,2)(1,3)(2,3) => 3
- 1 number combinations (1)(2)(3) => 3
if the nuber is 4
then you would have
- 4 number combinations (1,2,3,4) => 1
- 3 number combinations (1,2,3)(1,2,4)(1,3,4)(2,3,4) => 4
- 2 number combinations (1,2)(1,3)(1,4)(2,3)(2,4)(3,4) => 6
- 1 number combinations (1)(2)(3)(4) => 4
and so on...
i wouldn't need different order combinations just the combinations itself and again the number could be anything though its unlikely to be over 10
does anyone know a way to code this so any given nubmer it will produce the combinations?
at the moment i have hard coded up to 5 numbers but its alot of coding, there has to be a simpler way of doing it :)
Hope this makes sense :) Any help/directions to go woud be hugely appreciated
Thanks