시배's Android
Algorithm | 백준 Kotlin 2553 마지막 팩토리얼 수 본문
2553번: 마지막 팩토리얼 수
첫째 줄에 N이 주어진다. N은 20,000보다 작거나 같은 자연수 이다.
www.acmicpc.net
private fun main() {
val n = readln().toInt()
var result = 1L
for (i in 1..n) {
result *= i
result %= 10000000
while (result % 10 == 0L) {
result /= 10
}
}
println(result % 10)
}
'Algorithm' 카테고리의 다른 글
Algorithm | 백준 Kotlin 3273 두 수의 합 (0) | 2023.10.07 |
---|---|
Algorithm | 백준 Kotlin 6443 애너그램 (0) | 2023.09.23 |
Algorithm | 백준 Kotlin 1158 요세푸스 문제 (0) | 2023.09.23 |
Algorithm | 백준 Kotlin 1965 상자넣기 (0) | 2023.09.16 |
Algorithm | 백준 Kotlin 15664 N과 M (10) (0) | 2023.09.16 |