🌍 Public
Viewing a saved revision (read-only)
5c6ef1224b6f4a04a598c7de3c240f28
Algorithms 2
This example compares two algorithms for summing integers from 1 to n: a loop-based approach and a direct mathematical formula. The page displays the console output of both functions, `addNumbers` and `addNumbersFormula`, for n=10, showing that both return the same result. The plain HTML body sets a 13em font size, while the JavaScript uses standard `console.log` calls to print the labeled results. The visualization emphasizes algorithmic efficiency by contrasting the loop’s O(n) time complexity against the formula’s constant-time execution.
AI-generated description