As I mention in my comment, y
grows quadratically in your function, so the running time is O(sqrt(n)), not O(logn).
In the case of your simple algorithm, you can put a count in the while loop, to count how many times it runs for different values of n. This will give you a good starting point for figuring out what you want to prove.
To actually prove it, just figure out a formula for y
. You can get a handle on that by calculating y
for small values. You'll see a pattern.