Skip to content

Instantly share code, notes, and snippets.

@wicksome
Created November 8, 2019 03:36
Show Gist options
  • Select an option

  • Save wicksome/f1ec29c69d99df12e910e532f6b82cbe to your computer and use it in GitHub Desktop.

Select an option

Save wicksome/f1ec29c69d99df12e910e532f6b82cbe to your computer and use it in GitHub Desktop.

Revisions

  1. wicksome created this gist Nov 8, 2019.
    19 changes: 19 additions & 0 deletions Solution.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    publi class Solution {
    public int[] solution(int n, int m) {
    int[] answer = {gcd(n, m), lcm(n, m)};
    return answer;
    }

    private int gcd(int a, int b) { // 최대공약수
    while (b > 0) {
    int tmp = a;
    a = b;
    b = tmp % b;
    }
    return a;
    }

    private int lcm(int a, int b) { // 최소공배수
    return a * b / gcd(a, b);
    }
    }