This formula will eventually give you an idea of which chord will fit the melody. However you will be restricted to simple chords in the form of I IV V with a relevant minor. It will not tell you if it needs a diminished chord, maj7 chord, a sus4 chord, a b5 chord , a 9th chord, 13th chord, etc, etc...