in reply to Re: Prime Number Finder
in thread Prime Number Finder
There's an interesting O(1) algorithmYou do have to execute the algorithm on a classical computer, so Q::S or not, it's most definitely not O(1). It'll be exponential (in the number of bits in $n) because behind the scenes, Q::S is dividing $n by all possible factors (what else could it be doing?). But even on a quantum computer, you still need either a division or gcd circuit (and probably a lot of other stuff), which will take some polynomial time in the number of bits.
Just because it's a one-liner doesn't make it O(1). Anyway, my favorite cutesy inefficient primality checker is
sub is_prime { ("1" x $_[0]) !~ /^(11+)\1+$/ }
blokhead
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Prime Number Finder
by Roy Johnson (Monsignor) on Nov 11, 2005 at 21:47 UTC | |
by blokhead (Monsignor) on Nov 11, 2005 at 22:58 UTC | |
by gu (Beadle) on Nov 12, 2005 at 21:22 UTC | |
by Roy Johnson (Monsignor) on Nov 12, 2005 at 03:38 UTC | |
by blokhead (Monsignor) on Nov 12, 2005 at 15:01 UTC |