From a130afac66d4e95519b95af5bae125fd30ed95a1 Mon Sep 17 00:00:00 2001 From: Cassandra Portlock Date: Sun, 5 Nov 2023 19:59:03 -0800 Subject: [PATCH 1/2] completed assignment007 --- src/MyMath.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/MyMath.java b/src/MyMath.java index 7da9a29..bd49379 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -1,7 +1,33 @@ +/** + * + * @author Trevor Hartman + * @author Cassandra Portlock + * + * @since Version 1 + * + */ + import java.util.Scanner; public class MyMath { + private final static Scanner s = new Scanner(System.in); + public static void gcf() { + System.out.print("Type first number to find greatest common factor: "); + int a = s.nextInt(); + + System.out.print("Type first number to find greatest common factor: "); + int b = s.nextInt(); + + while (b != 0) { + int gcf = a; + a = b; + b = gcf % b; + } + + System.out.printf("The Greatest Common Factor is: %s", a); + } public static void main(String[] args) { + gcf(); } } From 1aea858bfaa9f86d76cfcca6487ac43bf23ca1bc Mon Sep 17 00:00:00 2001 From: Cassandra Portlock Date: Sun, 5 Nov 2023 20:05:55 -0800 Subject: [PATCH 2/2] completed assignment007 --- src/MyMath.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MyMath.java b/src/MyMath.java index bd49379..6bc01ac 100644 --- a/src/MyMath.java +++ b/src/MyMath.java @@ -19,9 +19,9 @@ public static void gcf() { int b = s.nextInt(); while (b != 0) { - int gcf = a; + int c = a; a = b; - b = gcf % b; + b = c % b; } System.out.printf("The Greatest Common Factor is: %s", a);