#### You may also like ### Helen's Conjecture

Helen made the conjecture that "every multiple of six has more factors than the two numbers either side of it". Is this conjecture true? ### First Forward Into Logo 1: Square Five

A Short introduction to using Logo. This is the first in a twelve part series. ### First Forward Into Logo 10: Count up - Count Down

What happens when a procedure calls itself?

# Mystery Procedure

##### Age 14 to 16 Challenge Level:

This procedure calculates the highest common factor of A and B.

The algorithm swaps over A and B to ensure A > B. We know hcf(A,B) $\leq$ min(A,B) = B in this case. Therefore, the first guess for N = hcf(A,B) is B. It first tests whether N is a factor of B. If that's the case, it then tests whether it's a factor of A. If either of these fail, it decreases N by 1. Eventually, it will either stop at a value of N>1 such that N divides A and B, or will terminate when N=1 (as A/1 and B/1 are both whole numbers). In the latter case, A and B are coprime.