  | 
  | 
 
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
hi,
posting my (naive) implementation of the "Euclidean"[*] method to calculate the
gcd, in case it'll be of use to others.  googling for "gcd" (and spelled out) on
the news.povray site, surprising to me, got zero results.
[*] <https://en.wikipedia.org/wiki/Greatest_common_divisor#Euclidean_algorithm>
regards, jr.
 
 Post a reply to this message 
 
Attachments: 
Download 'gcd.pov.txt' (1 KB)
 
  
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Hey, that's a really interesting algorithm! I'm inspired to learn how that
works. Thanks!
Kind regards,
Dave Blandston
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
hi,
"Dave Blandston" <IsN### [at] protonmail ch> wrote:
> Hey, that's a really interesting algorithm! I'm inspired to learn how that
> works. Thanks!
heh, better you than me!  :-)  I can follow how it works, and given sufficient
time I might even have thought of subtracting all multiples of B from A, but
then to swap B + A, never, I simply lack understanding of even the basic
"properties" of numbers.  hope your brain can take the "edutainment" ;-).
regards, jr.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 13/01/2022 17:30, jr wrote:
> hi,
> 
> posting my (naive) implementation of the "Euclidean"[*] method to calculate the
> gcd, in case it'll be of use to others.  googling for "gcd" (and spelled out) on
> the news.povray site, surprising to me, got zero results
To make it easier to use, you can also make :
(do not pay attention to the order of parameters)
#macro m_gcd(a_,b_)
  #local ta_ = max(a_,b_);
  #local tb_ = min(a_,b_);
  #while (tb_)
  ...
;)
-- 
Kurtz le pirate
Compagnie de la Banquise
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
hi,
kurtz le pirate <kur### [at] gmail com> wrote:
> To make it easier to use, you can also make :
> (do not pay attention to the order of parameters)
>
> #macro m_gcd(a_,b_)
>   #local ta_ = max(a_,b_);
>   #local tb_ = min(a_,b_);
>   #while (tb_)
>   ...
neat.  although the condition is not the same, accepting A = B makes no
(practical) difference, afaict.  thanks.
regards, jr.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 
 | 
  |