"Method" is correct and works, in the sense that it will give correct numbers in general. Unfortunately you will not be able to condense your expressions significantly. You would then, among other things, likely need a formula for the nth prime, and btw the exact same set up of inclusion/exclusion and floors can be used to express the prime counting function, for which there is very likely no short and elementary formula.