JAVA_LeetCode 2427_Number of Common Factors 풀이 class Solution { public int commonFactors(int a, int b) { // 1부터 a, b중 최대값만큼 반복하여 두수 모두 나눴을때 0인경우를 체크한다. int res = 0; for(int i = 1; i <= Math.max(a, b); i++){ if(a % i == 0 && b % i == 0) res++; } return res; } } * 출처 https://leetcode.com/problems/number-of-common-factors...
JAVA_LeetCode 2427_Number of Common Factors에 대한 요약내용입니다.
자세한 내용은 아래에 원문링크를 확인해주시기 바랍니다.