Kitorp and His Love

Limits: 1s, 256 MB

Kitorp loves his wife Asiar(who is a problem solver as well) but he loves math more. To get his attention, his wife took him to a bar and then they both got drunk. But now, being drunk, Kitorp can think more about math. Suddenly he came up with a math problem. He asked his wife, “We all know how to find the number of zeros at the end of factorial of a number.” Being angry, his wife asked him to do the opposite of it. She said, “I give you a number x, find the smallest number n, such that n! (factorial n) ends with exactly x zeros.” Now, Kitorp wants to find out the result, otherwise his wife will be more angry. So he seeks your help. As Asiar is also drunk, there might be cases when there are no such number n. In that case Kitorp will get angry and will say, “Go Home! You are drunk!”.

This is a companion discussion topic for the original entry at