Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Such restriction would only work in languages which support arbitrarily-long integers. Otherwise you'd have to pass the inputs as strings, only enforcing the "naive" approach.
Yup I meant
n
to be amount of digits, but now I see how confusing this is. If we want to relate it to input numbers themselves, it would be O(log n) I believe. Or something.I'm pretty sure hobovsky had
n(the one used inside O) = len(str(argument))
in mind, but FArekkusu thought both are the same.The first number which requires 4 iterations to get the result has 23 digits, and the first number which requires 5 iterations has 2 sixtillion digits - could you explain where this
O(n)
comes from?Also, posting solutions is prohibited, and may lead to a ban.
This comment is hidden because it contains spoiler information about the solution
This kata really should reject O(n) solutions...
Now do it in O(1).