161. Python Program to Find the GCD and LCM of Two Numbers
MediumImport
Overview
Import one function with from ... import ... and call it by its own name.
Problem Statement
Read two whole numbers, one per line (both are 1 or more). Print their GCD (greatest common divisor: the biggest number that divides both) and their LCM (lowest common multiple: the smallest number both divide into). For example, for 12 and 18:
GCD: 6
LCM: 36
Import gcd with from math import gcd. The LCM is a * b // gcd(a, b).
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
Two whole numbers, one per line. Example:
12
18
Output
The output for that example:
GCD: 6
LCM: 36
The tests try 4 different inputs.