Question: Mersenne function, something strange?

Hello

I'd like to understand how the mersenne function works in Maple.
I typed :

> with(numtheory):
> interface(verboseproc=2);
> print(mersenne);

That printed out :

proc (n::{posint, [posint]})
  option `Copyright (c) 1992 by the University of Waterloo. All rights reserved.`;
  if nargs <> 1 then error "wrong number of arguments" end if;
  if type(n, ['posint']) then
    if nops(w) < n[1] then error "index too large" end if; 2^w[n[1]]-1
  else
    if member(n, w) then 2^n-1 elif n < w[-1] or not isprime(n) then false else FAIL end if
  end if
end proc

If you have a look at the type of the argument, we can see that it can be both a positive integer and a list of positive integer. In the help the use of it is explained (at least, we can guess by the examples)

Actually, when you feed in a simple positive integer, it answers "false" if the mersenne is not prime, it prints out the value of the mersenne number if it is prime, and prints out "FAIL" if there's a problem.

The mersenne function's source, is not clear for me at all. What is that "w" ? Where is the prime test ? Is it hidden within the "member(n, w)" statement ?

Thank you for answering...

Regards,

 

MrCode

Please Wait...