/* This is HW4_5 Lab EE107
The purpose of this function an lcm and gcm
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Due Date: April 26th, 2024.
*/
#include <stdio.h>
// Function to calculate the greatest common divisor (GCD) of two integers
int gcd_EU(int u_EU, int v_EU) {
int temp_EU;
while (v_EU != 0) {
temp_EU = u_EU % v_EU;
u_EU = v_EU;
v_EU = temp_EU;
}
return u_EU;
}
// Function to calculate the least common multiple (LCM) of two integers
int lcm_EU(int u_EU, int v_EU) {
return (u_EU * v_EU) / gcd_EU(u_EU, v_EU);
}
int main() {
int num1_EU, num2_EU;
// Get user input for two numbers
printf("Enter first positive integer: \n");
scanf("%d", &num1_EU);
printf("Enter second positive integer: \n");
scanf("%d", &num2_EU);
// Calculate and print the LCM
printf("LCM of %d and %d is %d\n", num1_EU, num2_EU, lcm_EU(num1_EU, num2_EU));
// Calculate and print the GCD
printf("GCD of %d and %d is %d\n", num1_EU, num2_EU, gcd_EU(num1_EU, num2_EU));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: