Skip to main content
9 of 22
added 7 characters in body
Bálint
  • 1.9k
  • 15
  • 26

#Javascript 182 177 bytes (valid)

c=[0];n=prompt().split("");for(;c.join()!=n.join();){a=c.length-1;c[a]++;e=0;for(;--a>=0;){c[i]+=e;e=0;if(c[i]>9)c[i]=0,e++;}e?c.splice(0,0,1):0;alert(c.join().replace(",",""));} 

Arbitary precision to the rescue!

Because javascript can only count up to 2^53-1 (Thanks goes to @MartinBüttner for pointing it out), I needed to create arbitary precision to do this. It stores data in an array, and each "tick" it adds 1 to the last element, then goes trough the array, and if something exceedes 9, it sets that element to 0, and adds 1 to the one on the left hand.

Try it here! Note: press F12, to actually see the result, as I didn't want to make you wait for textboxes.

BTW.: I was the only one, who didn't know, ternary operators are so useful in codegolf?

if(statement)executeSomething(); 

is longer than

statement?executeSomething():0; 

by 1 byte.

#Javascript, 34 bytes (invalid - see comments)

n=prompt();for(i=0;i++<n;)alert(i) 

#Javascript 49 bytes (Just because it was allowed)

alert("every integer from `1` to `n` inclusive.") 

OP changed the rules :(

Bálint
  • 1.9k
  • 15
  • 26