Read Mode

Print Prime Numbers | By kvc

Print Prime Numbers | By kvc 
The Prime numbers are basically very important numbers, they plays very important roles in various algorithms and calculations. While calculating Prime numbers, I've used the unique property of prime numbers that they have only 2 divisors, i.e. '1' and the number itself... so, I've made two batch files for calculating prime numbers but the algorithm by which they are calculating prime numbers is slightly different. Due to this reason, one is calculating prime numbers faster than other.
Two different Algorithms

Slower Algorithm:
This Batch file is simply working blindly on the same fact that a prime number has only two divisors... and repeating the second nested for loop until the number is achieved itself...So, it makes the loop slower as the number (which we have to check is prime or not) gets bigger and bigger... that's why I called this as slower algorithm...

Faster Algorithm:
This Batch file is based on the fact that if a number is not divisible by any of the basic numbers (i.e. 1 to 13) then it can be considered as prime number...'cuz all other numbers can be factorized by these basic numbers. I'm not so sure about the working of this algorithm, But it worked fine when i tested it 12 to 15 times. so, I'm almost sure about it. You can match the results with results of slower algorithm program...whose output can be considered as perfect result...

Keep learning, keep sharing…
Be happy, spread happiness…

Download Link: Prime Numbers.Zip


No comments:

Powered by Blogger.