★ CODING ★ AMSTRAD ACTION DISCOURSE - DRAIM'S ALGORITHM TO FIND A PRIME FACTOR OF A NUMBER|Amstrad Action) ★ |
Amstrad Action Discourse - Draim's Algorithm to Find a Prime Factor of a Number |
More Greek with JAMES WILSON, who proves that after all there's not very much new under the sun. (Erastosthenes, for example, calculated the circuinference of the earth almost exactly - and that was 2,000 years ago!) Ptolemy III, named Eurgetes (247-222 BC), continued the tradition of his grandfather in fostering the Great Alexandrian Library and encouraged the librarian Erastosthenes (276-194 BC) who is often considered to be the most learned man of antiquity. Erastosthenes measured the earth by measuring the difference in the length of Che shadows cast by the sun's rays at Alexandria and Syene, which was known to be 50,000 stadia due south. He arrived at a figure of 250,000 stadia, about 25,000 miles - just 100 miles Dver the actual equatorial circumference! Like all the sages of his era, Erastosthenes spent some time studying numbers. He is probably best remembered for the 'Sieve of Erastosthenes.' This method for finding the Prime Numbers operates thus - Write down the integers (whole numbers;. Circle tlie two, then strike out every second integer. Put a circle around 3 then strike out every third integer. The next un-struck integer is 5, so circle it and strike out every fifth integer. Proceed thus and the only unstruck integers will be circled and are the Prime Numbers. Navy moves In 1952 an interesting Prime Factor algorithm was published after its discovery by Captain N.A. Draim of the US Navy. In effect, this algorithm operates by sieving out the primes as possible factors of a number. However for simplicity, the form of the algorithm that sieves out the odd numbers generally will be propounded here. It is left to the amusement of the reader to make it more efficient. To explain and show how tlie algorithm proceeds an example and its algebraic equivalent axe given in parallel in the box below. There then follows a Basic Program which corresponds exactly to the algebra. As in all the Discourse programs, change the value of a, the window parameter, if you want to re-direct the output to a printer. In order to make the algorithm use less data memory, only the results from the current iteration and the one before are retained line 130 effects the switch as each iteration is completed.
|