lua for loop

-- Define the start value for the loop variable
for i = 1, 5 do
  -- Loop body: code to be executed in each iteration
  print("Iteration " .. i)
end
  1. Initialization: i is initialized with the value 1.

  2. Condition Check: Check if the value of i is less than or equal to 5.

  3. Execute Loop Body: If the condition is true, execute the code inside the loop body.

  4. Update Variable: Increment i by 1 after executing the loop body.

  5. Repeat: Go back to step 2 and repeat the process until the condition is false.

  6. Termination: Exit the loop when the condition is false.