Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 코딩테스트
- hash table
- Tree
- simulation
- Matrix
- database
- sorting
- 자바
- dynamic programming
- two pointers
- Method
- Counting
- 파이썬
- bit manipulation
- Binary Search
- SQL
- 코테
- Binary Tree
- string
- Math
- Stack
- implement
- Class
- geometry
- Data Structure
- 구현
- array
- Number Theory
- greedy
- java
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 팩토리얼 본문
1. Input
1) 정수 n
2. Output
1) k! <= n을 만족하는 가장 큰 정수 k
3. Constraint
1) 0 < n <= 3628800
4. Example
Input: n=7 -> Output: 3
설명: 3! = 3*2*1 = 6이고 4! = 4*3*2*1 = 24이므로 k! <= 7을 만족하는 가장 큰 정수는 3
5. Code
1) 첫 코드(2022/10/26)
int i = 1;
while(true){
int fac = 1;
for(int j=1 ; j<=i ; j++)
fac *= j;
if(fac>n)
return i-1;
else if(fac==n)
return i;
else
i++;
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 문자열 정렬하기 (1) (0) | 2022.10.27 |
---|---|
[프로그래머스/Lv.0] 모음 제거 (0) | 2022.10.27 |
[프로그래머스/Lv.0] 최댓값 만들기 (1) (0) | 2022.10.26 |
[프로그래머스/Lv.0] 합성수 찾기 (0) | 2022.10.26 |
[프로그래머스/Lv.0] 주사위의 개수 (0) | 2022.10.26 |