Maths - Sample 1 - The prime factors

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. As you may know, there is a single way to decompose an interger in
prime factors. I think it is maybe a good method to calculate the list of prime numbers.
When a number cannot be factorized, it means it is a new prime number I add in the list.
Check the javascript code of this page where I explain my method.

More samples and useful functions here