1 prime number found

Maths - Sample 2 - Prime numbers obtained faster

In the MATHS section I want to find and share useful ways to deal with mathematical
concepts that are often used in games. Let's play with algorithms and discuss together
to optimize them. In the previous sample I was factorizing in prime numbers all the numbers
and found it was a way to build the list of prime numbers. In fact a number that cannot be
divided by all the previous prime numbers is a prime. In this sample I optimized the method
by not trying to find the whole factorization of each number and eliminating the ones that can
be divided by a prime number. I also reversed the way to consider prime numbers as potential divisors.
Check the javascript code of this page where I explain my method. I will try to improve it to increase
the speed of calculation that is drastically decreasing as time goes by.

More samples and useful functions here