Info
This question is closed. Reopen it to edit or answer.
find the integer factorization using pollard's p-1 method.
1 view (last 30 days)
Show older comments
this code is execuate for n=299.but fail for n=20.where is the problem?
clc;clear all;
n=input('Enter a composite number: ');
p=2;
i=2;
k=1;
d(1)=gcd(p-1,n);
d1(k)=n/d(k);
while gcd(p-1,n)==1
p=rem(p^i,n);
i=i+1;
d(k)=gcd(p-1,n);
d1(k)=n/d(k);
if isprime(d1(k))==true && isprime(d(k))==true
break;
elseif isprime(d(k))==true && isprime(d1(k))==false
n=d1(k);
k=k+1;
p=2;
i=2;
else
end
end
disp(d)
disp(d1)
2 Comments
the cyclist
on 30 Jul 2021
Can you share the source that you used for the algorithm? I looked at this article Wikipedia, but your code doesn't seem to correspond to the algorithm there.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!