Hi all,

I have developed an algorithm to find factors of a given number. Thus
it also helps in finding if the given number is a prime number. I feel
this is the fastest algorithm for finding factors or prime numbers.

I have put the algorithm here:
http://randomoneness.blogspot.com/2011/04/algorithm-to-find-factors-or-primes-in.html
This one finds if a give number is prime in say time frame of 5*N
(where N is the input number). So I hope I can call this a linear time
algorithm.

Can anybody verify the above for me?

A faster version of algorithm i put here:

Input: A Number (whose factors is to be found)
Output: The two factor of the Number. If the one of the factor found
is 1 then it can be concluded that the
Number is prime.

Integer N, mL, mR, r;
Integer temp1; // used for temporary data storage
mR = mL = square root of (N);
/*Check if perfect square*/
temp1 = mL * mR;
if temp1 equals N then
{
  r = 0; //answer is found
  End;
}
mR = N/mL; (have the value of mL less than mR)
r = N%mL;
while r not equals 0 do
{
  mL = mL-1;
  r = r+ mR;

  temp1 = r/mL;
  mR = mR + temp1;
  r = r%mL;
}
End; //mR and mL has answer

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to