Prime NumbersThere is no published formula to quickly guarantee that a large number is prime. The technique below is reliable for small numbers but it cannot be used on large numbers because it takes too long. The realistic limit for maximum testable number will vary (due to computer hardware etc.) Although you cannot quickly 100% guarantee that a large number is Prime, there is a technique that "usually" works. This technique is often associated with encryption and it can accept very large integers (4098 bit numbers are "routine" within Computer Security systems.)
The Function uses a special .NET class for BigInteger, which is not switched-on by default. This means that the IDE/Compiler may initailly complain about any line containing the the keyword BigInteger
To overcome the problem, you have to "add a reference" to your project by following these steps
- Click on "Project" (in top menu)
- Click on "Add Reference"
- Click on "System Numerics"
- Ensure Tick Box next to "System Numerics" is ticked
Phone Number (UK)
Premium Rate Phone Number (UK)
The code functions on this site are only intended as a learning aid. Data validation is often ommited to assist users unfamiliar with Visual Basic. The information may be untested, unreliable or unsuitable for your requirements. It is presented in a non-commercial form as an ex-gratia attempt to be helpful. By making any use of information contained on these pages, you agree to fully absolve and indemnify DigitalDan in relation to any issue arising out of such use.