From 4485d00e02ef746fe892d1ac1f807818c9ea883c Mon Sep 17 00:00:00 2001 From: LiviMcK <137836813+LiviMcK@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:12:20 -0700 Subject: [PATCH 1/3] finished assignment 7 --- .idea/misc.xml | 2 +- src/MyMath.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..433a737 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/MyMath.java b/src/MyMath.java index 7da9a29..e943b3f 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -1,7 +1,22 @@ import java.util.Scanner; +/** + * @author Olivia McKittrick + */ public class MyMath { - + public static int gcf(int a, int b) { // the two numbers + while (b != 0) { // while statement that continues as long as b is not = 0 + int temp = b; // temporarily stores b in temp to keep the original b value + b = a % b; // updates the value of b + a = temp; // updates value of a with value of b stored in temp + } + return a; + } public static void main(String[] args) { + int num1 = 1112; + int num2 = 695; + + int result = gcf(num1, num2); + System.out.println("The GCF of " + num1 + " and " + num2 + " is " + result); } } From 696a3c79ed26522e54b07416f16919a6175a4687 Mon Sep 17 00:00:00 2001 From: LiviMcK <137836813+LiviMcK@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:18:35 -0700 Subject: [PATCH 2/3] finished assignment 7 --- src/MyMath.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MyMath.java b/src/MyMath.java index e943b3f..431ee56 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -2,6 +2,7 @@ /** * @author Olivia McKittrick + * @date 10/31/23 */ public class MyMath { public static int gcf(int a, int b) { // the two numbers From e37564ab29fa4f74ec93282b92351e5ed2722d11 Mon Sep 17 00:00:00 2001 From: LiviMcK <137836813+LiviMcK@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:20:26 -0700 Subject: [PATCH 3/3] finished assignment 7 --- src/MyMath.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MyMath.java b/src/MyMath.java index 431ee56..99d77be 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -3,6 +3,7 @@ /** * @author Olivia McKittrick * @date 10/31/23 + * */ public class MyMath { public static int gcf(int a, int b) { // the two numbers