Jump to content

Perfect numbers: Difference between revisions

Line 2,822:
<syntaxhighlight lang="parigp">isPerfect(n)=sigma(n,-1)==2</syntaxhighlight>
Show perfect numbers
<syntaxhighlight lang="parigp">forprime(p=2, 2281,
forprime(p=2, 2281,
if(isprime(2^p-1),
print(p"\t",(2^p-1)*2^(p-1))))</syntaxhighlight>
</syntaxhighlight>
===Faster with Lucas-Lehmer test===
<syntaxhighlight lang="parigp">p=2;n=3;n1=2;
121

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.