A perfect example!?
08-30-2015, 09:24 AM
Post: #1
 StephenG1CMZ Senior Member Posts: 918 Joined: May 2015
A perfect example!?
The HP User Guide has an example so perfect I must share it with you.

There is an example procedure to check whether a number is a perfect number, and a test procedure showing the perfect numbers up to 100. The first of which is 6.
OK, all looking good.
To familiarise myself with my new calculator, I typed this in.
I was curious as to whether -6 was also a perfect number and also wanted to check that the Is Perfect routine didn't contain any nasties, like looping forever on an unexpected negative.
It didn't loop forever. But now it showed 1 as the first number.
Checking Wikipedia, 1 isn't a perfect number.
So why did Isperfect originally not show 1, and then did?

Inspecting the test harness, that is described as showing all perfect numbers up to 100, we see that it actually begins testing at 2, rather than the more obvious 1 or 0, which is why it never checked whether Isperfect was working correctly for 0 or 1.

Some more suspicious than I might wonder whether someone knew there was a bug in Isperfect and adjusted the test harness to avoid revealing the bug. Or whether other HP tests pass similarly.

But as it is, this example is a perfect example for debugging, and teaching that it's best to put the recognition test in one place, not - in effect - putting some "is it" tests in a separate routine.

Stephen Lewkowicz (G1CMZ)
08-30-2015, 09:47 AM
Post: #2
 Paul Dale Senior Member Posts: 1,733 Joined: Dec 2013
RE: A perfect example!?
1 isn't prefect for the same reason 1 isn't prime -- it doesn't make sense.

BTW: all even perfect numbers are of the form: 2pā1(2p ā 1) is an even perfect number when 2pā1 is prime

It is still unknown if there exists an odd perfect numbers.

Pauli
08-30-2015, 07:00 PM
Post: #3
 debrouxl Member Posts: 258 Joined: Dec 2013
RE: A perfect example!?
OT: the computations led by the OddPerfect project, using factorizations of their own and from other sources (Brent composites, RSALS / NFS@Home, etc.), indicate that if any odd perfect numbers exist, they must be quite large.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)