Skip to main content
Commonmark migration
Source Link

#Javascript 182 177 160 154 139 138 132 bytes (valid)

Javascript 182 177 160 154 139 138 132 bytes (valid)

1 byte saved thanks to @ShaunH

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}} 

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, 28 bytes (invalid - can't count to 264)

Javascript, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 

#Javascript 182 177 160 154 139 138 132 bytes (valid)

1 byte saved thanks to @ShaunH

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 

Javascript 182 177 160 154 139 138 132 bytes (valid)

1 byte saved thanks to @ShaunH

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 
added 5 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26

#Javascript 182 177 160 154 139 138138 132 bytes (valid)

1 byte saved thanks to @ShaunH

c=[e=0];n=prompt();forn=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 

#Javascript 182 177 160 154 139 138 bytes (valid)

1 byte saved thanks to @ShaunH

c=[e=0];n=prompt();for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 

#Javascript 182 177 160 154 139 138 132 bytes (valid)

1 byte saved thanks to @ShaunH

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 
deleted 6 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26

#Javascript 182 177 160 154 139 138 bytes (valid)

1 byte saved thanks to @ShaunH

c=[e=0];n=prompt();for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)} 

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, 3428 bytes (invalid - can't count to 264)

n=prompt();forn=>{for(i=0;i++<n;)alert(i)} 

#Javascript 182 177 160 154 139 138 bytes (valid)

1 byte saved thanks to @ShaunH

c=[e=0];n=prompt();for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)} 

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 - can't count to 264)

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

#Javascript 182 177 160 154 139 138 bytes (valid)

1 byte saved thanks to @ShaunH

c=[e=0];n=prompt();for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)} 

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, 28 bytes (invalid - can't count to 264)

n=>{for(i=0;i++<n;)alert(i)} 
added 44 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 4 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 4 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 6 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 3 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 4 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 125 characters in body
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393
Loading
added 6 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 7 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 7 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 7 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 814 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 3 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 3 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 466 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 464 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
added 23 characters in body
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading
deleted 2 characters in body
Source Link
Adnan
  • 44.7k
  • 6
  • 83
  • 248
Loading
Source Link
Bálint
  • 1.9k
  • 15
  • 26
Loading