Python Algorithms for Computer Science - Euclid Algorithm

 

Euclid Algorithm for computer science - python: GCSE, IGCSE, AS, A Level GCE OL, GCE AL

Euclid's Algorithm is one of the oldest algorithms known to  mankind. It was found in Euclid's Elements, something that dates back to 300 B.C.

When Euclid came up with the algorithm, mathematics was not known as it is today; in fact, he used geometrical methods in his discovery, as algebra was not known at that time, as a branch of mathematics.

Euclid's algorithm is used to find the HCF - Highest Common Factor - or GCD - Greatest Common Divider - of two numbers.

The following image shows the steps in the algorithm:

Euclid's algorithm
This is the flowchart for the algorithm:

Euclid algorithm - flowchart

You can practise the algorithm with the following Python code snippet:


If you want to practise the JavaScript version, please follow this link.





Comments

Popular posts from this blog

Phase Difference between Two Points on a Wave and Path Difference Explained - interactive