Hi
This method gives the simplest inverse calculation method available. so as to give the way of checking prime numbers in computer machine calculus.
Generally, for decomposition, only odd numbers within sqrt ( M ) need to be determined, so the computational complexity can also be greatly reduced.
Obviously, you also have better ways to improve the details.
The following is a process note, which can be directly transferred. It uses one loop to complete the decomposition of multiple prime numbers ( if any ) in a composite number )We have a large number B and need to decompose its prime factor
1, First, it is determined whether the large number can be squared.
If you can't square into the [for loop], the loop of times is the size of a large number B.
2, Set a counter p ( for P = 1,B, P + + )
3, Let [ B ]and[ p ] each time to get the number N = B /P, and judge whether the [N] is an integer or float.
4, If B can be divided exactly, set a counter J to clear and then J to add 1
5, If J is 1
Then use the division result [N] of division the above large number to check the end and deterNine if N is odd, if odd,J + 1
6, Judge whether the end of P+ N is even, if even, J + 1
7, If j = 3 and I > 1, then stop loop, output .
8, Count Arrived, Stop Cycle
We can find the [P] and [N] varian is prime number.
(B/P)mod 2=((N+P)mod 2 )+1
You can also find the formula in the doc file.