APPLICATIONSDIVERS ★ Discourse II ★

Discourse II|Amstrad Action)Applications Divers
★ 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 ★ 

If CPC techie-talk is all Greek to you, let JAMES WILSON, in the second of this series, demonstrate why.

Euclid's Algorithm brings to light a remarkable property of the Highest Common Factor (HCF) which is not obvious if the H.C.F. is determined by factorisation into primes. This property is that the highest common factor, h, of two natural numbers a and b is representable as the difference between a multiple of a and a multiple of b, that is

h = ax - by

where x and y are natural numbers.

One reason why this property is so interesting is that equations of this form were extensively studied by Diophantus (ca. 180 AD), probably the best, ancient algebraist, and are today often referred to as Diophantine Equations.

The only known woman mathematician of the ancient Alexandrian school, Hypatia, recognised this (alas, she was battered to death by Christian fanatics in about 415 AD).

Diophantus was the first to employ signs (for positive and negative) systematically and he also used symbols for unknowns, powers and so on He solved linear, quadratic and at least one cubic equation.

In some of his methods he effectively used the device of approximating to limits, a method eventually systematized by Sir Issac Newton in the 1670's as Calculus.

Using his limit technique, Diophantus attempted to divide 13 into two square numbers, each of which is to be greater than 6. He arrived at squares with sides of 258/101 and 257/101.

Clearly, in all these matters, the knowledge as to whether any given number is prime (that is. divisible by only itself and 1) or not is of utmost importance. If any number is not divisible by any prime number in the range 2 up to its square root then that number itself must be prime. The process of checking the divisibility 

of a number by the primes is very laborious and many mathematicians have developed methods to reduce this labour.

Gauss (1777-1855) and Pierre Format (1601-1665) were quite successful and Fermat's method, which is extremely simple in principle, is explained below.

Let P be the number we wish to test and

let n be the lowest number such that n> P. All we have to do now is form the series of numbers

n2 - P , ( n + 1) 2 - P , ( n + 2 ) 2 - P ...

If a number is reached which is a perfect square then we have

x2 - p = y2 and thus P = X2 - Y2 = (X = y);

If P is prime then the solution we reach gives x + y-Pand x - y = 1.

The difference between each term of the series is 2n = m wherein is 1,3.5.... as the algorithm progresses.

An example illustrates this best. Let P = 9271. This lies between 962 and 972 , so  that n = 97. Our series is thus

n- P    972 - 9271 = 9409 - 9271 = 138
+ 2n + 1                          = 333
+ 2n + 3                          = 530
+ 2n + 5                          = 729
+ 2n + 7                          = 930

but 729 is the perfect square of 27, thus we have x2 - 9271 = 729. Therefore x=100 and, from above , P = (x + y)(x - y) , 9271 = 123 x 73.

The program below docs exactly this. Line 90 takes on the number to be factorised, which should be greater than 1000, and as an integer, less than 32767.

Line 110 calculates the starting value of n. e is the integer value to test if the value of the series member r is a perfect square, which is done in the gosub 300 routine. If r is a perfect square the subroutine returns f = 1 and drops to Line 250, when the Factors are calculated and printed in Line 280.


AA

★ PUBLISHER: AMSTRAD ACTION
★ YEAR: 1989
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LICENCE: LISTING
★ AUTHOR: JAMES WILSON

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Discourse  2    LISTINGDATE: 2014-03-24
DL: 6 fois
TYPE: PDF
SIZE: 93Ko
NOTE: 1 page/PDFlib v1.6

Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)
★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Printer Font Designer (Computing With the Amstrad)
» Applications » Codage Turbo pour Imprimantes (CPC Revue)
» Applications » Degrees Conversion
» Applications » Biorythm Graphing and Prediction
» Applications » Screen Dump For Epson (Computing With the Amstrad)
» Applications » Real Time Clock (Computing with the Amstrad)

QUE DIT LA LOI FRANÇAISE:

L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 159 millisecondes et consultée 524 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.