While8. An integer N (> 0) is given. Find the largest integer K which square does not exceed N: \(K^2 \leq N\). Do not use the function of extracting the square root.

Solution in Python 3:

import random

N = random.randrange(1,1000)
#N = 100
print('N = ', N)

K = 1
while K*K <= N:
K += 1
K -= 1
print("K = {0}, K^2 = {1}, (K+1)^2 = {2}".format(K,K**2,(K+1)**2))