I am trying to solve this problem:

You are given two strictly positive integers *N* and *K*, where . Find the first *K*′, where *K*′ > *K*, such that . It's obvious that such a number must exist. It's a known fact that as *K* varies over the strictly positive integers, the number of distinct values takes is exactly . However, I haven't been able to find a way to jump to the next value in the sequence quickly. I'm looking for an *O*(1) solution, even would be too slow.

Thank you.

It works. Thanks!

How to prove that takes exactly distinct values for ?