You can find this amazing article from Microsoft MVP Emiliano Musso here, on TechNet Wiki:
In this article, Emiliano takes you through a simple method to factorize a number into its prime factors. It uses Small Basic, which can be downloaded at http://smallbasic.com/. Once installed, you'll be ready to go.
Check out the different sections of this article:
Table of Contents
- Requesting input
- Calculate primality
- Spotting factors
- Showing results
- Source code
- PNF on SmallBasic.com
- See Also
Let's include one example of the code used. This is to...
We've seen above that to check if a number is prime, we need to test its divisors up to the square root of the number itself. We must test each of those divisors, checking if the division give back no remainders. That can be done as follows:
The source code from this article is available for testing and download at: http://smallbasic.com/program/?LLS908
Remember to head to the article for all the sections:
And special thanks to Emiliano for this great addition to the Small Basic library of content!
Small and Basically yours,
- Ninja Ed