1
$\begingroup$

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.

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

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-SymbolicTensors`UtilitiesDump`temp$maxRankedN$328507} does not have appropriate bounds. >>

[...]

Out[9]= SymbolicTensors`UtilitiesDump`RankedPerfectNumber[18]

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

$\endgroup$
  • $\begingroup$ 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). $\endgroup$ – Jacob Akkerboom Mar 3 '16 at 18:56
  • $\begingroup$ I got confused because the error for Do with a large range is the same as the message generated PerfectNumberQ for a large number. $\endgroup$ – Jacob Akkerboom Mar 3 '16 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.