Skip to content

Instantly share code, notes, and snippets.

@speckworks
Last active June 17, 2020 13:04
Show Gist options
  • Save speckworks/13755468d93f7706469db37a6cc24560 to your computer and use it in GitHub Desktop.
Save speckworks/13755468d93f7706469db37a6cc24560 to your computer and use it in GitHub Desktop.
//In this Algorithm there is only on variable "i" declared and it contains a number.
//Even though that number can increase to an arbitrarily large value (according to input n),
//Space Complexity is constant since it's just 1 value that is changing.
const logUpToN(n) => {
for(let i = 1; i <= n; i++){
console.log(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment