(Find the smallest n such that n^2>12,000) Use a while loop to find the smallest integer n such that n^2 is greater than 12,000.
Program code:
# Initialize the counter and n
counter = 1
n = 1
# Use a while loop to find the smallest n
#such that n^2 is greater than 12,000
while n**2 <= 12000:
n += 1
counter += 1
# Display the result
print("The smallest integer n such that n^2 is greater than 12,000 is:", n)
print("n^2 =", n**2)
print("Number of iterations:", counter)
Executed Output:
The smallest integer n such that n^2 is greater than 12,000 is: 110
n^2 = 12100
Number of iterations: 110