본문 바로가기

Coding Test/프로그래머스

[프로그래머스/자바] 팩토리얼

class Solution {
    public int solution(int n) {
        int temp = 1;
        int num = 1;
        while(temp <= n){
            temp *= num;
            if(temp > n) break;
            num++;
        }
        return num - 1;
    }
}