From: Jimmy Kofler Date: 2008-04-16T16:36:57+09:00 Subject: Re: Primes in P? > Posted by Todd Benson (Guest) on 01.04.2008 14:08 > >> On Tue, Apr 1, 2008 at 5:19 AM, Todd Benson wrote: >> >> >> Charles, take a peak at the mathn library for your greatest prime factor... >> >> require 'mathn' >> n = 12345654321 >> p n.prime_division.last[0] > > Funny, I tried this with the same number with a 1 attached to the end > (123456543211). It took about 20 minutes, but determined it was prime > (i.e. returned [123456543211, 1]) which means 123456543211 to the > power of 1. Coincidence :) > > Todd Well, you could use the Miller-Rabin prime test for a speed up! See: http://snippets.dzone.com/posts/show/4636 You may check the outcome with primegen, http://cr.yp.to/primegen.html time -p primes 123456543211 123456543211 # done in well under a second Cheers, j. k. -- Posted via http://www.ruby-forum.com/.