mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Homework Help (https://www.mersenneforum.org/forumdisplay.php?f=78)
-   -   Calculating perfect numbers in Pascal (https://www.mersenneforum.org/showthread.php?t=10388)

Elhueno 2008-06-11 06:30

Calculating perfect numbers in Pascal
 
Hi all i was just wondering if anyone here has ever tried to calculate perfect numbers from scratch in Bloodshed softwares Dev-Pascal. i have been tasked to do this for a college teacher. any help would be appreciated. and the sooner the better.

R.D. Silverman 2008-06-11 13:01

[QUOTE=Elhueno;135656]Hi all i was just wondering if anyone here has ever tried to calculate perfect numbers from scratch in Bloodshed softwares Dev-Pascal. i have been tasked to do this for a college teacher. any help would be appreciated. and the sooner the better.[/QUOTE]

What do you mean by "calculate perfect numbers"? Do you mean

"write a program that will find p such that 2^p-1 is prime?"

Once you have such p, then a perfect number is just (2^p-1) * 2^(p-1)
Hint: this has already been done.

Or do you mean

"given a list of such p, compute 2^(p-1) * (2^p -1)"??

If so, you must again specify what you mean by "compute".

Do you mean "calculate the decimal representation"? or "calculate the
hex representation"? or "calculate the binary representation"?? [the latter
two are trivial].

Mini-Geek 2008-06-11 13:22

[quote=R.D. Silverman;135672]What do you mean by "calculate perfect numbers"? Do you mean

"write a program that will find p such that 2^p-1 is prime?"

Once you have such p, then a perfect number is just (2^p-1) * 2^(p-1)
Hint: this has already been done.

Or do you mean

"given a list of such p, compute 2^(p-1) * (2^p -1)"??

If so, you must again specify what you mean by "compute".

Do you mean "calculate the decimal representation"? or "calculate the
hex representation"? or "calculate the binary representation"?? [the latter
two are trivial].[/quote]
I'd assume he meant a program that finds perfect numbers by factoring numbers, adding their factors, then seeing if those two are equal. A better way to calculate, as you suggested, would be to find Mersenne primes (preferably by LL test) and know the perfect numbers by that.
I think a better, revised question would be how to write the LL test in Pascal.

Housemouse 2008-06-12 13:00

Any program to search for an odd perfect number, if any exist?

bsquared 2008-06-12 13:08

[quote=Housemouse;135752]Any program to search for an odd perfect number, if any exist?[/quote]

[URL="http://www.oddperfect.org"]www.oddperfect.org[/URL]

philmoore 2008-06-12 16:37

My impression of the original poster's request was that this was an assignment in programming rather than a math project. My guess is that the teacher wanted a program, which for each integer input n, computed the sum of proper divisors of n to see if it is equal to n, perhaps contained in a loop incrementing n. This can be done in a very simple-minded (and inefficient) way, or one could apply a bit of math to make the search more efficient. Perhaps the original poster should clarify what is really wanted.


All times are UTC. The time now is 22:03.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.