A Note on Least Absolute Remainder Euclidean Algorithm for Greatest

0 downloads 0 Views 196KB Size Report
Mar 4, 2018 - Abstract. In this note we gave new implementation of Least. Absolute Remainder Euclidean Algorithm for. Greatest Common Divisor ...
International Journal of Scientific Engineering and Applied Science (IJSEAS) – Volume-4, Issue-3, March 2018 ISSN: 2395-3470 www.ijseas.com

A Note on Least Absolute Remainder Euclidean Algorithm for Greatest Common Divisor Anton Iliev1,2, Nikolay Kyurkchiev1,2 1

Faculty of Mathematics and Informatics, University of Plovdiv Paisii Hilendarski, 24, Tzar Asen Str., 4000 Plovdiv, Bulgaria, e-mails: [email protected], [email protected] 2 Institute of Mathematics and Informatics, Bulgarian Academy of Sciences, Acad. G. Bonchev Str., Bl. 8, 1113 Sofia, Bulgaria

Abstract In this note we gave new implementation of Least Absolute Remainder Euclidean Algorithm for Greatest Common Divisor (LAREAGCD). The reason of this interest is that this is another different point of view to this problem [54, 36]. In every book of algebra and algorithms the Euclidean algorithm is part of basic examples [1-31], [33-54].Visual C# 2017 programming environment is used. Keywords: greatest common divisor, least absolute remainder, Euclidean Algorithm, Knuth’s algorithm, reduced number of iterations. 1. Introduction Our work is continuation of research in [28-32]. LAREAGCD is known (see [41]): Algorithm 1. do { q = a / b; r = a - b * q; ar = Math.Abs(r - b); a = b; if (r 0); gcd = a;

with the following programing environment (see Fig. 1.).

2. Main Results

We present the following algorithms.

Fig. 1. Visual C# 2017

Algorithm 2 is recursive implementation of Algorithm 1:

Now we set the task to optimize LAREAGCD. For testing we will use the following computer: processor - Intel(R) Core(TM) i7-6700HQ CPU 2.60GHz, 2592 Mhz, 4 Core(s), 8 Logical Processor(s), RAM 16 GB, Microsoft Windows 10 Enterprise x64.

Algorithm 2. static long Euclid(long a, long b) { long q = a / b; long r = a - b * q; long ar = Math.Abs(r - b); a = b; if (r b) gcd = Euclid(a, b); else gcd = Euclid(b, a);

d += gcd; } Console.WriteLine(d);

New realization of Algorithm 1: Results of Part 1.: Time of Algorithm 1: Time of Algorithm 2: Time of Algorithm 3: Time of Algorithm 4:

Algorithm 3. if (a > b) do { q = a / b; r = a - b * q; ar = Math.Abs(r - b); a = b; if (r

Suggest Documents