Procedure
Real Lab Procedure
# Function to calculate the Greatest Common Divisor (GCD) using the Euclidean algorithm
- def gcd(m, n):
- while n != 0:
- r = m % n # Calculate the remainder
- m = n # Update m to n
- n = r # Update n to the remainder
- return m # Return the final GCD
# Function to calculate the Least Common Multiple (LCM) using the relationship with GCD
- def lcm(m, n): # m and n containing value of variale a and b respectively
- prod = m * n # Calculate the product of the two numbers
- g = gcd(m, n) # Calling the previously defined GCD function
- l = prod // g # Calculate the LCM using the formula: LCM(a, b) = (a * b) / GCD(a, b)
- return l # Return the final LCM
# Get user input for two numbers
- a = int(input("Enter the first number: "))
- b = int(input("Enter the second number: "))
- d = lcm(a, b) # calling the lcm function to calculate least common multiplier between a and b
- print("d") # display the LCM on screen
Simulator Procedure
- Initiate the execution by clicking the 'START' button in the code segment.
- Proceed by pressing the forward button (green colour) to execute the code.
- When prompted for user input, enter the required information in the designated area and click the submit button near to it.
- Wait until the data exchange in the data segment is complete before clicking the forward button again.
Requirements
The program provided is a simple Python script that should run on a variety of systems with minimal hardware and software requirements.
Hardware Requirements
Computer: Any modern computer capable of running Python.
Input Devices: Keyboard (for entering input).
Software Requirements
Python: Python 3.0.x or newer.
Code Editor or IDE: PyCharm 2023.3 or above / Atom 1.57.0 or above / IDLE 3.13 or newer.