Skip to content

This Batch program contains algorithms for calculating 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 other.

License

TheBATeam/Print-Prime-Numbers-With-Notepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Print-Prime-Numbers-With-Notepad

This Batch program contains algorithms for calculating 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 other.

Print Prime Numbers | By kvc

HOW TO PRINT PRIME NUMBERS IN CMD? | BATCH

Two different Algorithms – Same OUTPUT!

CALCULATE PRIME NUMBERS – SLOWER ALGORITHM:

Concept: This Batch file is simply working blindly on the same fact that a prime number has only two divisors, 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 the slower algorithm.

CHECK PRIME NUMBERS – FASTER ALGORITHM:

Concept: 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 accuracy in all cases of this algorithm , but it worked fine when tested it 12 to 15 times.

Update: I’ve Again Checked the Faster Algorithm – And, Luckily Found Some Flaws. Using the slower algorithm gives the correct answer with all integers.

Look at the Difference in the OUTPUT of PRIME NUMBERS UPTO 1000 – with both the Algorithms.

-Kvc

Read Full Article

About

This Batch program contains algorithms for calculating 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 other.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published