728x90
SMALL

using System;

public class Solution {
    public int solution(int n) {
        int temp = 1;
        int answer = 1;
        int i =0;
        
        for(i=1;i<10;i++)
        {
            temp *= i+1;
            if(temp <= n)
            {
                answer++;   
            }
        }
        return answer;
    }
}

 

/////

 

using System;

public class Solution {
    public int solution(int n) {
        int temp = 1;
        int answer = 0;
        int i = 1;
        
        while(temp <= n)
        {
            temp *= i+1;
            answer++;
            i++;
        }
        
        return answer;
    }
}

 

파이썬

////

 

from math import factorial

def solution(n):
    k = 10
    while n < factorial(k):
        k -= 1
    return k

///////////

def solution(n):
    answer = 1
    factorial = 1
    while factorial <= n:
        answer += 1
        factorial = factorial * answer
    answer -= 1
    return answer

 

자바

////

 

class Solution {
    public int solution(int n) {
        int answer = 1;
        int factorial = 1;

        while(n >= factorial) 
        {
            answer ++;
            factorial *= answer;
        }
        return answer -1 ;
    }

}

 

728x90

설정

트랙백

댓글