# PerfectNumber messes with my iterator

I am using Mathematica 10.4 (sorry bbgodfrey) (temporary message)

Let

mmVerbose = 10^2000 + 123123798797192983712873198273122323;
kkVerbose = 10^7;


The following gives an error.

Do[PerfectNumber[iterator],
{iterator, mmVerbose, mmVerbose + kkVerbose}]


But the following doesn't.

Do[1, {iterator, mmVerbose, mmVerbose + kkVerbose}]


Also a loop with a time consuming argument does not give an error.

Do[Pause[3];
Print@iterator, {iterator, mmVerbose, mmVerbose + kkVerbose}]


I can accept that Do guards against ranges that are too big, like in the following code.

Do[1, {iterator, 1, mmVerbose + kkVerbose}]


I am wondering what makes PerfectNumber so special and why the Message is displayed. Note that you can use PrintDefinitions on PerfectNumber and get a lot of information.

• PerfectNumber is not recognized in 10.3.1. What version are you using? Mar 3 '16 at 17:37
• @bbgodfrey PerfectNumber is a new function in Mathematica 10.4.0 Mar 3 '16 at 17:38
• ...but what is the message that you get? Mar 3 '16 at 18:01

The error message does not come from your own Do loop, but from a Do loop inside the PerfectNumber code somewhere:

In[9]:= PerfectNumber[mmVerbose]

During evaluation of In[9]:= Do::iterb: Iterator {100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123123798797192983712873198273122323-SymbolicTensorsUtilitiesDumptemp$maxRankedN$328507} does not have appropriate bounds. >>

[...]

Out[9]= SymbolicTensorsUtilitiesDumpRankedPerfectNumber[18]


I think this can be tagged as a bug in PerfectNumber not handling large arguments perfectly. I reported it to the developer.

• Ah yes I came to this conclusion also. I have a bad internet connection at the moment, so I didn't catch yours. I think it is kind of reasonable that PerfectNumber does not handle the large input, I think it probably the number PerfectNumber[2^63 + 1000] would not fit in the universe. I guess a nicer error message could have helped, but I don't want to be too harsh on symbols with attribute ReadProtected (and visible definitions). Mar 3 '16 at 18:56
• I got confused because the error for Do with a large range is the same as the message generated PerfectNumberQ for a large number. Mar 3 '16 at 19:15