diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..116ab47 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/MyMath.java b/src/MyMath.java index 7da9a29..bb603bd 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -1,7 +1,24 @@ -import java.util.Scanner; - +/* +// ChrisShortt +12/7/2023 +*/ public class MyMath { - public static void main(String[] args) { - } -} + // Method to calculate the Greatest Common Factor (GCF) of two numbers + public static int gcf(int num1, int num2) { + while (num2 != 0) { + int temp = num2; + num2 = num1 % num2; + num1 = temp; + } + return num1; + } + + // Example usage in a main method + public static void main(String[] args) { + int a = 12; + int b = 18; + int result = gcf(a, b); + System.out.println("The GCF of " + a + " and " + b + " is: " + result); + } + } \ No newline at end of file