Purpose: Purpose:
You may make a copy of a worksheet and complete this activity, or simply type your answers in any text editor.
You may work alone or with another student in this course.
Consider the following Java method
// Calculate_LCM takes two numbers and
// return LCM (Lease Common Multiplier) of the two numbers
// Examples:
// LCM of 12 and 15 = 2 * 2 * 3 * 5 = 60
// LCM of 12 and 18 = 2 * 2 * 3 * 3 = 36
// LCM of 15 and 18 = 2 * 3 * 3 * 5 = 90
public static int Calculate_LCM(int n1, int n2)
{
int result = 1;
int i = 2;
if (n1 > n2)
result = n1;
else
result = n2;
int temp = result;
while (result % n1 != 0 || result % n2 != 0)
{
result = temp * i;
i++;
}
return result;
}
| Test requirements | Test paths | Test cases (input values and expected output) |
| Test requirements | Test paths | Test cases (input values and expected output) |
| Test requirements | Test paths | Test cases (input values and expected output) |
| Test requirements | Test paths | Test cases (input values and expected output) |
CC-BY-NC-SA 4.0 license.