Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Edu59
Posts:
4
Registered:
9/1/11


A combinatorial problem
Posted:
Oct 1, 2011 9:07 AM


Hi: I am trying to solve this mathematical problem with an unknown matlab builtin function. Let K=1?20 be the set of the first 20 integers. Consider all combinations of 5 elements selected from the set K. How many of these combinations contain elements that differ by 3? For example, the combination (1,4,5,9,15) has elements 1 and 4 whose difference is 41=3 but the combination (1,2,3,9,15) has no elements that differ by 3. So the combination (1,4,5,9,15) is one I am looking for and the combination (1,2,3,9,15) is not. What is the total number of combinations like (1,4,5,9,15) taken from the first 20 integers.? I tried the following procedure: With the builtin matlab function combntns I can enumerate the combinations of n objects taken p at a time and then I can use the function size to calculate the total number of combinations for example:
How can the numbers 1 to 5 be taken in sets of three (that is, what is 5 choose 3)? combos = combntns(1:5,3) combos = 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5 size(combos,1) % "5 choose 3" ans = 10
Is there a matlab function that enumerates combinations with elements that differ by 3 and then use a function like size to compute the total number of combinations.? Thank you in advance.



