Ad
  • Custom User Avatar

    I think there should be an example where a term of the sum is divided more than one time. For example:
    k-divide(8, 2) = sum(1, 1, 3, 1, 5, 3, 7, 1) = 22
    The first time I didn't catch the part about repeating the operation, as the instruction mentioned dividing twice. My fault, but I think the it could be rewritten clearer and shorter. Maybe

    For each integer from 1 to N, perform the following operation:

    1. If the number is divisible, divide by K, and repeat
    2. Otherwise, end the operation