(Vocational Technical Group) Answers to the 11th Blue Bridge Cup Provincial Demo Competition] What is the greatest common divisor of 70044 and 113148?

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

  1. 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.

[(Vocational Specialist Group) Answers to the 11th Blue Bridge Cup Provincial Demo Contest] Among the positive integers not exceeding 19000, what are the numbers that are prime to 19000?

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);
    }
}
Published 137 original articles · 120 praised · 20,000 views +

Guess you like

Origin blog.csdn.net/weixin_43124279/article/details/105665665