A loop runs the same code repeatedly, making it useful when a calculation must be performed for many inputs. A trigonometric table, for instance, needs a value at each angle rather than a separate handwritten calculation for every row. section 3.1
A `while` loop repeats its body while a Boolean condition is true. In `i = 0; while i < 5; i += 1; println(i); end`, updating `i` eventually makes the condition false. The loop does not display its own result in the REPL: a `while` expression evaluates to `nothing`. Use `print` or `println` when you want to see values produced along the way. section 3.3
When the values to visit are known, a `for` loop removes the manual counter update. `for i in 0:4; println(i); end` prints 0 through 4. The range `0:15:90` visits angles from 0 through 90 in steps of 15. A range is an iterable: an object a `for` loop can visit one value at a time. section 3.3.4
Repeated calculations can take several forms:
- Build a factorial with `while`: start a product at 1, multiply by `n`, and decrease `n` until it falls below 1. section 3.5
- Calculate a Fibonacci number with `for i in 2:n`, updating the previous and current values on each pass. This replaces recursive calls with explicit bookkeeping. section 3.10.2
Iteration and recursion can solve the same problem. Recursion may be simpler to write, while iteration often performs better; choose according to the clarity and performance the task needs. Beyond ranges, Julia collections can support `for` loops by providing iteration methods. section 3.10.2 section 12.8


























