(Find the largest n such that n^3< 12,000) Use a while loop to find the largest integer n such that n^3 is less than 12,000.
Program code:
# Initialize variables
n = 0 # Start with n = 0
cubed = 0 # Store the cube of n
# Use a while loop to find the largest n such that n^3 < 12,000
while cubed < 12000:
n += 1 # Increment n by 1
cubed = n ** 3 # Calculate the cube of n
# After the loop, n will be the largest integer such that n^3 < 12,000
# But since we incremented n before checking the condition, we need to decrement it by 1
n -= 1
# Print the result
print("The largest integer n such that n^3 is less than 12,000 is:", n)
Executed Output:
The largest integer n such that n^3 is less than 12,000 is: 22