티스토리 뷰

import java.io.*;
import java.util.*;

class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
int result = 1;
while(n != 0) {
result *= n;
n--;
}
System.out.println(result);
}
}


간단.


10! = 3628800 이므로 시간복잡도가 계승으로 나올 때는 답이 없다는 것을 알 수 있다.



var n = Int(readLine()!)!

var result = 1

for i in stride(from: 1, through: n, by: 1) {

    result *= i

}

print(result)



'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글

2004번 '조합 0의 개수'  (0) 2018.08.01
1676번 '팩토리얼 0의 개수'  (0) 2018.08.01
11653번 '소인수분해'  (0) 2018.08.01
6588번 '골드바흐의 추측'  (0) 2018.08.01
1929번 '소수 구하기'  (0) 2018.08.01
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
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
글 보관함