The least common multiple (lcm) or its logarithm (for example Log2) can be used as a dissonance measure for intervals and chords.
chord
http://en.wikipedia.org/wiki/Least_common_multiple