You can't patent ideas, and "finding prime numbers" unfortunately isn't really a tangible process.
You'd be better off going for a patent on a use for that formula. Coming up with a use for such a thing is out of the scope of this site, but I'd suggest looking into encryption. As far as I know, that's the heaviest use of prime numbers out there. I don't know, granted, whether your formula would be useful there or not.
Speaking to the part of your question that is on-topic, however, inventions need to have practical utility to be patentable. "Utility" is, of course, a somewhat subjective term, and it leaves a lot up for interpretations by the patent office and, ultimately, courts. But speaking as broadly as I may through a format such as this, it would be difficult to argue a theoretical mathematical formula as innately having real-world applicability. You'd likely have more luck digging for an implementation of that formula, then somehow patenting the use of that formula to achieve that practice.
There's an interesting grey-area in one, reported in a story in the New York Times, where a financial formula was deemed as having direct real-world applications because a court found it to directly make money. It's, unfortunately, unlikely that your pure-math formula would find a similar conclusion.
As far as cross-applicability over platforms is concerned, that's another interesting question. That depends a bit on how the patent is phrased. I suspect you'd be able to get something, as long as you could overcome the inherent struggle of patenting a formula like this.
Your best bet, rather unsurprisingly, would be to speak with a patent professional about your specific invention and its uses, then go from there. Many such professionals offer fairly cheap (or even free) initial consultations, where you could get a very good idea of what options you may have.
On a side note, and I know Pushpak mentioned this in comments, it is extremely important that you don't disclose your invention publicly prior to speaking with a patent professional and filing an application. In the United States, you're lucky enough to be given a one-year grace period from the time of public disclosure to the time of filing, but even in light of that, you're giving up some rights, including the ability to file elsewhere.