![[java] 백준 5086번 배수와 약수](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcOA8Rb%2FbtraWS5s0sN%2FaFlNd1EYzNX0DA3LbgTcr0%2Fimg.jpg)
알고리즘/백준2021. 7. 31. 22:19[java] 백준 5086번 배수와 약수
약수와 배수의 공통점은 나누었을 때 딱 나누어 떨어진다는 점이다. 그래서 두 수의 대소 비교만 해주면 약수와 배수를 구할 수 있을 것이라고 판단하여 아래와 같이 코드를 짰다. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) { break; } if (a b && a % b =..