[알고리즘문제풀기] 팩토리얼

silver's avatar
Dec 28, 2025
[알고리즘문제풀기] 팩토리얼

문제

내가 작성한 정답

class Solution { public int solution(int n) { int a = 0; int f = 1; while(f<=n){ a++; f *= a; } return a-1; } class Solution { public int solution(int n) { for(int i=1; i<=11; i++){ int f =1; for(int j=1; j<=i; j++) f *= j; if(f>n) return i-1; } return 0; } }

다른 사람들의 정답

class Solution { public int solution(int n) { int fac = 1; int i = 0; while(true){ if(fac <= n){ fac *= i + 1; i++; }else break; } return i-1; } }
Share article

silver