# Lesson goal: $\sqrt{n}-\sqrt{n-1}<0.01$

Previous: Solving equations | Home | Next: Introduction

Use a while-loop to find the smallest positive integer $n$, such that $\sqrt{n}-\sqrt{n-1}<0.01$.

Remember that $\sqrt{something}$ in Lua is math.sqrt(something).

What is your answer? a) 2499 b) 2500 c) 2501 or d) 10,000 e) there is no such integer. (From Artino, 1978, #18.)

# Now you try. Fix the while loop to stop when d becomes less than 0.01, and fix the d= line to compute $\sqrt{n}-\sqrt{n-1}<0.01$.

Show a friend, family member, or teacher what you've done!