Skip to content

[Algorithm] 최대공약수와 최소공배수 #85

Description

@hwangJi-dev

💬 문제

[코딩테스트 연습 - 최대공약수와 최소공배수](https://school.programmers.co.kr/learn/courses/30/lessons/12940)


💬 풀이

func solution2(n:Int, m:Int)->[Int]{varmax=1foriin1...(n > m ? n : m){if n % i ==0 && m % i ==0 && max < i {
max = i
}}return[max,(n * m)/ max]}

💬 알게된 것

  • 최소공배수 공식
    • 두 자연수의 곱 / 최대공약수

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions