Bug ? Wilson's Theorem
Sergei Steshenko
sergstesh at yahoo.com
Thu Dec 18 18:19:33 CST 2008
--- On Thu, 12/18/08, Okubok Kenjiro <okubok at nn.iij4u.or.jp> wrote:
> From: Okubok Kenjiro <okubok at nn.iij4u.or.jp>
> Subject: Bug ? Wilson's Theorem
> To: bug at octave.org
> Date: Thursday, December 18, 2008, 1:52 PM
> Sir
>
> I know octave is not a tool for number theory, but when I
> taught
> Wilson's theorem in a high-school I found a bug?
> Wilsons theorem says, for any prime number p, (p-1)!+1 is
> divisible by p;
> with octave
> rem(prod(1:(p-1)),p) must be zero, my students checked this
> for all
> primes less than 100. There was an exception for p=29,
> rem(prod(1:28),29), ans=3.514e+13.
> I am a retired mathematician worked in ODE, and am helping
> highschool
> boys after regular
> classes. To deal with large integers, I teach them to
> factorize into
> residual classes and their products. I guess octave changes
> its strategy
> at 29, resulting in this case.
>
> Kenjiro Okubo
> Prof. Emeritus UEC,Tokyo Japan
> _______________________________________________
Well, I'm not familiar with the theorem, but I have a question.
On the one hand, you're saying that (p-1)!+1 is divisible by p, on the
other hand you are trying rem(prod(1:28),29), where I would expect,
according to your statement, rem(prod(1:28) - 1, 29).
Anyway, neither works.
And can it be 28! has too many significant digits to fit mantissa of
standard double ?
...
It appears to be the case - in 'maxima' I'm getting this:
(%i4) 28!;
(%o4) 304888344611713860501504000000
, i.e. there are 23 significant digits.
Standard 'double' has mantissa for, I think, 14 decimal significant digits.
Try 'maxima'/'wxMaxima':
http://maxima.sourceforge.net/
http://wxmaxima.sourceforge.net/wiki/index.php/Main_Page
.
Regards,
Sergei.
More information about the Bug-octave
mailing list