# Does this equation have a name?

by gamow99
Tags: equation
 P: 9 Hey, computer scientist here. Cool project you're working on. I stumbled across this pattern while messing around with tabular K-map simplification (boolean logic): You have 4 variables (but this can be generalized to n variables) and are trying to find the total number of associative expressions such that AB = BA. (Looping through for A AND B as well as B AND A would be inefficient) This problem is analogous to finding the number of lines between a given number of points (see below). The formula is $$\frac{n^2-n}{2}$$ Send me a PM: I'd like to take a closer look at your logic calculator. *plus sign changed to minus sign as per jz92's post Attached Thumbnails
 P: 45 Does this equation have a name? The general equation for evaluating the number of unique combinations when you select k items from a set of n items is: $$\frac{n!}{(n-k)!*k!}$$ n choose 2 is $$\frac{n!}{(n-2)!*2!}$$ Simplified, it is: $$\frac{n^2-n}{2}$$ Comparing each combination of 2, where there are 4 sentences, comes out to a total of (16-4)/2, or 6 comparisons. This, of course, requires that the loops are set up in a way that you never test the same combination twice.