The least common multiple
Task
Write a function nsd(a, b) that returns the greatest common divisor of two positive whole numbers using Euclid's algorithm, and a function nsn(a, b) that returns their least common multiple. The relation nsn(a, b) = a * b // nsd(a, b) helps.
Do not use the math module.
Examples
Call
print(nsd(48, 18), nsn(4, 6))
Expected output
6 12
Rules
Write the calculation yourself - without the
mathmodule.
After you submit, 6 hidden tests will also check your solution: coprime numbers, equal numbers, one number is 1, one is a multiple of the other, the smaller number first, large numbers.
You need to know
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.