Ah ... aye, see what you mean. I've abused and have had a lot of success with Allen Browne's method?
Here is a link to it (I couldn't find it on his site).
Most of it could probably be deleted but calling your attention to the last 30 lines. If you could understand this, then it would be...