자바 lcm()

1 개요[ | ]

Java lcm()
자바 lcm()
import java.math.BigInteger;
public class MyClass {
    private static int lcm(int a, int b) {
        return (a*b)/BigInteger.valueOf(a).gcd(BigInteger .valueOf(b)).intValue();
    }
    public static void main(String args[]) {
        System.out.println( lcm(20,8) ); // 40
        System.out.println( lcm(12,21) ); // 84
        System.out.println( lcm(54,24) ); // 216
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}