CODING ★ AMSTRAD ACTION DISCOURSE - EUCLID'S ALGORITH TO CALCULATE THE H.C.F OF TWO NUMBERS|Amstrad Action #44) ★

Amstrad Action Discourse - Euclid's Algorith to Calculate the H.C.F of Two Numbers
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

You may already realise that many techniques used in computing are not that new at all.

But did you know that some of them are more than 2,000 years old? JAMES WILSON demonstrates.

Calculating was originally an activity performed by priests, and its advance, in early times, sat on the back of priestly philosophical discussions on the nature of their gods, on perfection and on the general shape of things.

The second of the Ptolemaic rulers of Egypt founded a library and museum at Alexandria in about 300 B.C. Amongst the first of the scholars to be called to this Alexandrian Academy was Euclid (C.330BC - C.260BC), that illustrious mathematician. He came from Athens where he had probably trained under Plato.

For the next 22 centuries, the first six books of his thirteen volume Elements of Geometry were the customary school intro duction to geometry. Although the work is called Elements of Geometry three of the volumes are devoted to the theory of numbers.

In Book 9, Proposition 20 is the proof that there is no 'highest Prime Number, a remarkable deduction in an area that has exercised great minds ever since.

In his tenth book he explored the irrational quantities, first discussed by Pythagoras, and to this day the subject of deep research by eminent mathematicians under dreaming spires.

Getting things in proportion

The theory of proportion is a geometric commonality that is discussed in his fifth book and gives rise to the theory of irrational numbers which was eventually developed by Rene Descartes (1596-1650).

Euclid also wrote a mathematical treatise on Optics. He believed that light moved in straight lines and that vision was something that went forth from the eye. Many of his other works on astronomy and music are lost lo us though some survive in Arabic translations of dubious accuracy.

The algorithm method

One especial loss is his work entitled On Fallacies which dealt with the causes of error in geometrical research. However, one remarkable legacy of this ancient sage is his algorithm, expounded in Proposition 2 of Book 7, for calculating the Highest Common Factor of two numbers. This algorithm is an excellent example of a mathematical process which only works correctly with integers (ie. whole numbers).

Let us choose any two whole numbers a and b, and suppose that a > b.

If a is not divisible by b then we can express a as a multiple of b together with a remainder which is less than b. that is

xa = kb + c where 0 < c < b

eg. 38 - 3 x 12 + 2

Any common divisor of b and c is also a divi-
sor of a. Also, any common divisor of a and b is also a divisor of c. And this is the crux of Euclid's Algorithm.

Ail example best illustrates this algorithm.

Take the numbers 4862 and 1793.

The algorithm runs as follows -

4862 = 2x1793 + 1276

1793 = 1 x 1276 +517

1276 - 2 x 517 + 242

5l7 = 2 x242+ 33

242 = 7x 33+ 11

33 = 3 x 11 + 0

and the H.C.F. is the 11, the last remainder. (For the aficionados, if, and only if, the last remainder of Euclid's algorithm when applied to two numbers is 1. then these two numbers are relatively prime and their H.C.F. is 1.)

The following program illustrates Euclid's Algorithm and was used to calculate the above result. If you want to print the result on your printer change the value of a in Line 60 to 8. I will be expanding on this algorithm later in this series.

Interestingly, the reasoning behind this algorithm can also be used to prove Proposition 30 of Book 7, the proposition often referred to as Euclid's Theorem:

If a prime divides the product of two numbers. then it must divide at least one of these two numbers.

AA

★ YEAR: 1989
★ AUTHOR: James Wilson
 

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Euclid  s  Algorith  to  Calculate  the  HCF  of  Two  Numbers    (Amstrad  Action)    ENGLISHDATE: 2021-02-06
DL: 263
TYPE: ZIP
SiZE: 3Ko
NOTE: 40 Cyls
.HFE: Χ

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Menue-Kosten-Programm (Schneider Aktiv)
» Applications » Titlemaker 4 (Ivan Cvetkovič)
» Applications » Histogrammes 3D (CPC Revue)
» Applications » Numérologie
» Applications » DBD7
» Applications » Premier (CPC Infos)
Je participe au site:
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.732-desktop/c
Page créée en 618 millisecondes et consultée 2070 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.