Perfect Number Generator

Finds even perfect numbers [ppN(:,3)] for each relevant prime <= P.
517 Downloads
Aktualisiert 12. Jan 2010

Lizenz anzeigen

It calculates perfect even #'s with 2^(p-1)*(2^p - 1) where p and (2^p - 1)
%are prime. A subsequent run yields a faster run-time. The code is fully
%vectorized and hence cleaner than previous versions of the function.
%NB: if (2^p - 1) is a Mersenne prime then a perfect number has been found.
%
%SYNTAX: >> perf_finalv4(P) % where P is an integer scalar in
%useful inclusive range [2..31].
%i.e. run showing first 8 perfect numbers...
%>> p = perf_finalv4(31);
%>> [p(:,3)]
%
% ans =
%
% 6
% 28
% 496
% 8128
% 33550336
% 8589869056
% 137438691328
% 2.30584300813995e+018

Zitieren als

Bruce Raine (2024). Perfect Number Generator (https://www.mathworks.com/matlabcentral/fileexchange/26314-perfect-number-generator), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2009b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Discrete Math finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.3.0.0

Corrected comments in function header i.e.
%2^43,112,608 × (2^43,112,609 - 1)
and also spelling typo. NB: neither change affects the function's performance.

1.0.0.0