as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
design a mathematical algorithm for finding the greatest common divisor of two numbers.
user
the algorithm should start by obtaining two numbers, 'a' and 'b'. then it should iterate through a loop and set 'r' equal to the remainder of 'a' divided by 'b'. if 'r' is not equal to 0, the algorithm should set 'a' equal to 'b' and 'b' equal to 'r'. this loop should be repeated until 'r' is equal to 0. then the algorithm should return 'a' as the greatest common divisor of two numbers.
assistant