Humans and Draenea add up to 9. In fact, as Humans are the only odd number, any odd number you would be search for would have to include Humans. Seems a backward search might work best. Take the target number 36, find the nearest less than 36 that equals a race, then search half that value until you come up with a value matching that equals your target. ie Target Num = 36 , closest match less than 36 = 32. Hold as a match for one race. 1/2 of 32 = 16 but 16 + 32 not equal Target Num of 36, then 1/2 of 16, then 1/2 of 8 until a race is reached that meets the Target Num. I'm not sure how many races you have but I think your way of numbering them holds a lot of promise for a backward searching formula. If the Target Num was an odd number, they one of the races has to be human.