POV-Ray : Newsgroups : povray.newusers : Prime numbers : Re: Prime numbers Server Time
10 Aug 2022 15:55:57 EDT (-0400)
  Re: Prime numbers  
From: Dick Balaska
Date: 28 Jan 2022 15:35:18
Message: <61f45386$1@news.povray.org>
On 1/22/2022 1:25 PM, kurtz le pirate wrote:

Once you've determined a number is not prime, you can skip testing.

> // -----------------------------------------------------------
> // --- macro to test if a it is a prime numbers
> // -----------------------------------------------------------
> #macro IsPrime(n)
>   #local cnt = 0;
>   #local i=2;
>   #while(i<n)
>    #if(mod(n,i)=0)
>     #declare cnt=cnt+1;
       #break
>    #end
>    #declare i=i+1;
>   #end
>   (cnt=0)
> #end


Post a reply to this message

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