Title: Greatest Common Divisor of 70044 and 113148
Problem description
What is the greatest common divisor of 70044 and 113148?
Answer submission
This is a question with the result filled in. You only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. You will not be able to score if you fill in the extra content.
Main points
- Start from 1 and increase by 1 each time to traverse the smallest number, from 1-70044, and then determine whether there is a divisor of 70044 and 113148, and then continuously update the divisor, which is the greatest common divisor when it terminates
answer
5388
handwriting
Calculate the divisors of the two separately, and then find the common divisor, and then find the largest one. It's
too troublesome. It's not recommended. If you want to do it by hand, but no, please see my previous blog.
Code
public class 最大公约数 {
public static void main(String[] args) {
int max = 0;
for (int i = 1; i <= 70044; i++) {
if (70044 % i == 0 && 113148 % i == 0) {
max = i;
}
}
System.out.print(max);
}
}