Basically they sum the stroke counts of the ideograms, and the total stroke count can be lucky or unlucky based on a number of rules. The only such rule I can bring to mind ATM is that if the number starts or ends in four it's unlucky because it contains the "shi" syllable that is linked to death (it's the root of the verb "to die", e.g. omae wa mou shindeiru from Hokuto no Ken).