Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    I'm pretty sure hobovsky had n(the one used inside O) = len(str(argument)) in mind, but FArekkusu thought both are the same.

  • Custom User Avatar

    This kata really should reject O(n) solutions...

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This kata really should reject O(n) solutions...

    Now do it in O(1).