Post History
JavaScript (Node.js), 60 bytes n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l} Try it online! Explanation n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);ret...
#5: Post edited
- # [JavaScript (Node.js)], 60 bytes
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}
- ```
- [Try it online]!
- ## Explanation
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*
- l=''; | Starting with an empty string...
- for( n; ); | ...loop while n still has hex digits (i.e. nonzero):
l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16- n>>=4 | then floor division by 16
- n=>{ return l} | (in an anonymous arrow function)
- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
- [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@CmG1to2v4J9aQkojCYYft4NGZ4Gp1NbUYwGWL4bOzAmXriV95@ubNc95/7UtWiGv1rPIDb1iuyspKaaNodD/mBZQUgFCFko5tx/X8WTAni2W8WifpeKsenWA3kVMVRdRHYcGrW6EsWTfTDc1GttUeGlndx9PIGewY28ZL45lxahwMedvk572D2OS93otFZ3f4v0pN3rY7ewnp7RGntUvIWtsnxO0cJ/FMO8NVIS4Q4fIqRQXBuwII6wqSPfuEUArFUZu@j9q1@p7U7fLBC4taky3GuI0Mj2kE0Nbe7fBRyIoXkOmL/wIBForJ24GXkCGEz7lQEAAU/o3OJccyP8GMf185q6yHezu81tX0JfODvnrZvL3iUi@tTuL4A1PYr4NQnelRNQqbXw "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 60 bytes
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}
- ```
- [Try it online]!
- ## Explanation
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*
- l=''; | Starting with an empty string...
- for( n; ); | ...loop while n still has hex digits (i.e. nonzero):
- l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16 on the left (so no +=)
- n>>=4 | then floor division by 16
- n=>{ return l} | (in an anonymous arrow function)
- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
- [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@CmG1to2v4J9aQkojCYYft4NGZ4Gp1NbUYwGWL4bOzAmXriV95@ubNc95/7UtWiGv1rPIDb1iuyspKaaNodD/mBZQUgFCFko5tx/X8WTAni2W8WifpeKsenWA3kVMVRdRHYcGrW6EsWTfTDc1GttUeGlndx9PIGewY28ZL45lxahwMedvk572D2OS93otFZ3f4v0pN3rY7ewnp7RGntUvIWtsnxO0cJ/FMO8NVIS4Q4fIqRQXBuwII6wqSPfuEUArFUZu@j9q1@p7U7fLBC4taky3GuI0Mj2kE0Nbe7fBRyIoXkOmL/wIBForJ24GXkCGEz7lQEAAU/o3OJccyP8GMf185q6yHezu81tX0JfODvnrZvL3iUi@tTuL4A1PYr4NQnelRNQqbXw "JavaScript (Node.js) – Try It Online"
#3: Post edited
# [JavaScript (Node.js)], 62 bytes- ```javascript
n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}- ```
- [Try it online]!
- ## Explanation
Simple algorithm.- ```javascript
n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*l=''; | Starting with an empty string...for( n>0; ); | ...loop while n still has hex digits (i.e. nonzero):l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16n>>=4 | then floor division by 16n=>{ return l} | (in an anonymous arrow function)- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
[Try it online]: https://tio.run/##RdBPb4IwGAbwu5@iMdvaRteUPyKGlEQUDjtsB4/OBIfV1dRiAJcths/OCpStJ37l6Zs3z3n/tS@zQlyrZ5UfeJPlqqxAwhrFwvsxL5BkEAYqpIFkY2rZjjvz5v5iGa3WcTLeqkfL203kVIUhc3FQ8OpWKCDrZrph6YiC9rAQdB9PI2uwZUyNl8Yz48TYG/LU5Oe9vcjknd6LRWd7@L9KTJ7Szk7s93Z8q7Xt@2tt1/ftzlEczbRTUhXigjApr1JUCL4riIkuId5nnwhJoThu0/dRu1bflLpdPngBGJhsCSFtZHjMQoi3dLcjRyErXqBMX/wXCIlQmbwdeIkyjMk5FwpBiIO/0bnkROYnlPLvK88q8HBvh9e6mr5kftBXL5u3V1LqpdVJHH9Qgvp1MK5TParGQfML "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 60 bytes
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}
- ```
- [Try it online]!
- ## Explanation
- ```javascript
- n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*
- l=''; | Starting with an empty string...
- for( n; ); | ...loop while n still has hex digits (i.e. nonzero):
- l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16
- n>>=4 | then floor division by 16
- n=>{ return l} | (in an anonymous arrow function)
- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
- [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@CmG1to2v4J9aQkojCYYft4NGZ4Gp1NbUYwGWL4bOzAmXriV95@ubNc95/7UtWiGv1rPIDb1iuyspKaaNodD/mBZQUgFCFko5tx/X8WTAni2W8WifpeKsenWA3kVMVRdRHYcGrW6EsWTfTDc1GttUeGlndx9PIGewY28ZL45lxahwMedvk572D2OS93otFZ3f4v0pN3rY7ewnp7RGntUvIWtsnxO0cJ/FMO8NVIS4Q4fIqRQXBuwII6wqSPfuEUArFUZu@j9q1@p7U7fLBC4taky3GuI0Mj2kE0Nbe7fBRyIoXkOmL/wIBForJ24GXkCGEz7lQEAAU/o3OJccyP8GMf185q6yHezu81tX0JfODvnrZvL3iUi@tTuL4A1PYr4NQnelRNQqbXw "JavaScript (Node.js) – Try It Online"
#2: Post edited
- # [JavaScript (Node.js)], 62 bytes
- ```javascript
- n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}
- ```
- [Try it online]!
- ## Explanation
- Simple algorithm.
```- n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*
- l=''; | Starting with an empty string...
- for( n>0; ); | ...loop while n still has hex digits (i.e. nonzero):
- l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16
- n>>=4 | then floor division by 16
- n=>{ return l} | (in an anonymous arrow function)
- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
- [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@iMdvaRteUPyKGlEQUDjtsB4/OBIfV1dRiAJcths/OCpStJ37l6Zs3z3n/tS@zQlyrZ5UfeJPlqqxAwhrFwvsxL5BkEAYqpIFkY2rZjjvz5v5iGa3WcTLeqkfL203kVIUhc3FQ8OpWKCDrZrph6YiC9rAQdB9PI2uwZUyNl8Yz48TYG/LU5Oe9vcjknd6LRWd7@L9KTJ7Szk7s93Z8q7Xt@2tt1/ftzlEczbRTUhXigjApr1JUCL4riIkuId5nnwhJoThu0/dRu1bflLpdPngBGJhsCSFtZHjMQoi3dLcjRyErXqBMX/wXCIlQmbwdeIkyjMk5FwpBiIO/0bnkROYnlPLvK88q8HBvh9e6mr5kftBXL5u3V1LqpdVJHH9Qgvp1MK5TParGQfML "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 62 bytes
- ```javascript
- n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}
- ```
- [Try it online]!
- ## Explanation
- Simple algorithm.
- ```javascript
- n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/*
- l=''; | Starting with an empty string...
- for( n>0; ); | ...loop while n still has hex digits (i.e. nonzero):
- l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16
- n>>=4 | then floor division by 16
- n=>{ return l} | (in an anonymous arrow function)
- 💎*/
- ```
- Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
- ## Caveats
- "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \
- <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub>
- [JavaScript (Node.js)]: https://nodejs.org
- [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@iMdvaRteUPyKGlEQUDjtsB4/OBIfV1dRiAJcths/OCpStJ37l6Zs3z3n/tS@zQlyrZ5UfeJPlqqxAwhrFwvsxL5BkEAYqpIFkY2rZjjvz5v5iGa3WcTLeqkfL203kVIUhc3FQ8OpWKCDrZrph6YiC9rAQdB9PI2uwZUyNl8Yz48TYG/LU5Oe9vcjknd6LRWd7@L9KTJ7Szk7s93Z8q7Xt@2tt1/ftzlEczbRTUhXigjApr1JUCL4riIkuId5nnwhJoThu0/dRu1bflLpdPngBGJhsCSFtZHjMQoi3dLcjRyErXqBMX/wXCIlQmbwdeIkyjMk5FwpBiIO/0bnkROYnlPLvK88q8HBvh9e6mr5kftBXL5u3V1LqpdVJHH9Qgvp1MK5TParGQfML "JavaScript (Node.js) – Try It Online"
#1: Initial revision
# [JavaScript (Node.js)], 62 bytes ```javascript n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l} ``` [Try it online]! ## Explanation Simple algorithm. ``` n=>{for(l='';n>0;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l}/* l=''; | Starting with an empty string... for( n>0; ); | ...loop while n still has hex digits (i.e. nonzero): l="0123456789ABCDEF"[n%16]+l, | add the hex digit corresponding to n mod 16 n>>=4 | then floor division by 16 n=>{ return l} | (in an anonymous arrow function) 💎*/ ``` Created with the help of [Luminespire](https://vyxal.github.io/Luminespire). ## Caveats "It should work at least for all inputs greater than 0 up to the language's default type limit." - the question. (i.e. returning an empty string for 0 is fine) \ <sub>"The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros." - Wikipedia, which agrees with my opinion, but that doesn't matter anyways as stated above</sub> [JavaScript (Node.js)]: https://nodejs.org [Try it online]: https://tio.run/##RdBPb4IwGAbwu5@iMdvaRteUPyKGlEQUDjtsB4/OBIfV1dRiAJcths/OCpStJ37l6Zs3z3n/tS@zQlyrZ5UfeJPlqqxAwhrFwvsxL5BkEAYqpIFkY2rZjjvz5v5iGa3WcTLeqkfL203kVIUhc3FQ8OpWKCDrZrph6YiC9rAQdB9PI2uwZUyNl8Yz48TYG/LU5Oe9vcjknd6LRWd7@L9KTJ7Szk7s93Z8q7Xt@2tt1/ftzlEczbRTUhXigjApr1JUCL4riIkuId5nnwhJoThu0/dRu1bflLpdPngBGJhsCSFtZHjMQoi3dLcjRyErXqBMX/wXCIlQmbwdeIkyjMk5FwpBiIO/0bnkROYnlPLvK88q8HBvh9e6mr5kftBXL5u3V1LqpdVJHH9Qgvp1MK5TParGQfML "JavaScript (Node.js) – Try It Online"