I am trying to work out this issue in a molecular caluclator that I am trying to develop. I would like to go from mass to formula.

So I am given a mass, ie 120.3433. And an equation could have up to 8 C, 3 H, 11 N, 6 S but they have to reasonable close to 120.3433. Just letting a person get a reasonable idea of what a formula could be if they were only given a mass. How do I get the different combinations?

for instance, C8H3N4S6, C7H3N4S6, C6H3N4S6, or something like that. Any help you could offer would be greatly appreciated.

If there is some clarification that you need, please let me know...