POV-Ray : Newsgroups : povray.off-topic : An unusual prime number algorithm : Re: An unusual prime number algorithm Server Time
11 Oct 2024 05:18:57 EDT (-0400)
  Re: An unusual prime number algorithm  
From: Warp
Date: 2 Dec 2007 12:23:30
Message: <4752ea12@news.povray.org>
Orchid XP v7 <voi### [at] devnull> wrote:
> -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
> -###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-
> -#####-###-#-###-#-#####-#-###-#-###-#####-###-#-###-#-#####-###-#-###-

  That last pattern is wrong. The first incorrectly (non-)marked place
is at 25. It also marks 41 as non-prime even though it is.

  Anyways, using the correct patterns, wuldn't it be better to preserve
the info about which of those are the primes?
  If we mark untested numbers with '-', primes with '!' and non-primes
with '#' then that would become:

-!-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
-!!#-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-#-###-
-!!#!#-###-#-###-#-###-#####-#-###-#-###-#-###-#-###-#####-#-#####-###-
-!!#!#!###-#-###-#-###-#####-#-#####-###-#-###-#####-#####-#-#####-###-

etc.

  In the end you end up with:

-!!#!#!###!#!###!#!###!#####!#!#####!###!#!###!#####!#####!#!#####!###

  OTOH using this algorithm you basically need to fix the number of
primes you want to calculate. It also requires random access so it's
not very usable with linked lists.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.