Я разработал алгоритм для поиска множителей заданного числа. Таким образом, это также помогает определить, является ли данное число простым. Я считаю, что это самый быстрый алгоритм поиска множителей или простых чисел.
Этот алгоритм определяет, является ли данное число простым во временном интервале 5 * N (где N - входное число). Так что я надеюсь, что могу назвать это алгоритмом линейного времени.
Как я могу проверить, является ли это самым быстрым из доступных алгоритмов? Кто-нибудь может помочь в этом вопросе? (быстрее, чем GNFS и другие известные)
Алгоритм приведен ниже
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
Пожалуйста, оставьте свои комментарии ... не стесняйтесь обращаться ко мне за дополнительной информацией.
Спасибо,
Как я могу проверить, является ли это самым быстрым из доступных алгоритмов? Кто-нибудь может помочь в этом вопросе? (быстрее, чем GNFS и другие известные)
Алгоритм приведен ниже
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
Пожалуйста, оставьте свои комментарии ... не стесняйтесь обращаться ко мне за дополнительной информацией.
Спасибо,
Как я могу проверить, является ли это самым быстрым из доступных алгоритмов? Кто-нибудь может помочь в этом вопросе? (быстрее, чем GNFS и другие известные)
Алгоритм приведен ниже
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
Пожалуйста, оставьте свои комментарии ... не стесняйтесь обращаться ко мне за дополнительной информацией.
Спасибо, Хариш http://randomoneness.blogspot.com/2011/09/algorithm-to-find-factors-or-primes-in.html