Print prime numbers – These are basically very important that they play very important roles in various algorithms and calculations. While calculating them, I’ve used the unique property of prime numbers that they have only 2 divisors, i.e. ‘1’ and the number itself.
PRINT PRIME NUMBERS
So I’ve made two batch files for calculations but the algorithm by which they are calculating prime numbers is slightly different. Due to this reason, one is calculating them faster than others.
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 a 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 a slower 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 numbers.
Because 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 a slower algorithm program whose output can be considered as a perfect result.
Keep learning, keep sharing…
Be happy, spread happiness…