[Question]
  [
> 
> Based off a Scratch project
> 
> 
> 
The pen extension in Scratch has a `set pen color to ()` block. The `()` is normally a color dropdown, but you can also use the `join()()` block. In the `join()()` block, normally a hex value is in the first input, but the second is just an empty string.
However, many new Scratchers that want to take advantage of this find it hard (after all we count in decimal). Your task today, is: given three positive integers `r`,`g`,`b`, calculate the hex value and return it as `#rrggbb`.
## Input:
`r`, `g`, `b`.
1. \$0\le r\le255\$
2. \$0\le g\le255\$
3. \$0\le b\le255\$
4. Input will always follow these rules
5. Input won't have leading zeros except for `0` itself
## Output
A string in the format `#rrggbb`. Hexadecimal letters can be all uppercase or all lowercase.
## Method
1. Convert `r`,`g`,`b` to hexadecimal
2. Concatenate `r`,`g`,`b`
3. Prepend a `#`
4. Return it
## Testcases:
```
r, g, b     -> Output
0, 127, 255   -> #007fff
1, 1, 1       -> #010101
245, 43, 2    -> #f52b02
72, 1, 134    -> #480186
0, 0, 0       -> #000000
255, 255, 255 -> #ffffff
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer wins!
**NOTE**: There's [an earlier question](https://codegolf.stackexchange.com/questions/13132/color-rgb-int-to-hex) that qualifies this as a duplicate, but it's closed (because the scoring criterion was ambiguous)
  
[Answer]
# [Python 3](https://docs.python.org/3.8/), 22 bytes
```
("#"+"%02x"*3).__mod__
```
[Try it online!](https://tio.run/##JYrbCsIwEAXf9yuWiJDUIM2NitA/EYJgSwM1DWW9fX1cKwyHwzDlQ9OS3amsdewvVYqdOIh9a9@iceoY4325xVhfU5oHNGdA6ofndZYplwdJpQDLmjLJUZJStdVobKfRhgCGPwPWB43esYTO/p3zwOUP4HLLt/kC "Python 3.8 (pre-release) ‚Äì Try It Online")
Takes inputs as a tuple. The idea is to avoid a `lambda` or `def` by [having the answer be an object method](https://codegolf.stackexchange.com/a/95156/20260).
Same length:
```
f"#{'%02x'*3}".__mod__
```
[Answer]
# [`[5,171,30]`üòâ - 05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 9 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
‚ÇÅ+h‚Ç¨¬¶J'#√¨
```
Input as list `[r,g,b]`. Outputs in uppercase.
[Try it online](https://tio.run/##yy9OTMpM/f//UVOjdsajpjWHlnmpKx9e8/9/tKmOobmhjrFBLAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/R02N2hmPmtYcWualrnx4zX@d/9HRhjpAGKsTbWRiqmNirGMEZJobgcSMTYBMAx1DI3MdI1NTMBsIQSpNTXWgGMgz1TE0N9QxNoiNBQA).
**Explanation:**
```
‚ÇÅ+         # Add 256 to each value in the (implicit) input-triplet
  h        # Convert each from integer to a hexadecimal string
   ‚Ç¨¬¶      # Remove the leading "1" from each string
     J     # Join them together
      '#√¨ '# Prepend a leading "#"
           # (after which the result is output implicitly)
```
[Answer]
# [C (GCC)](https://gcc.gnu.org), 39 bytes
```
m(r,g,b){printf("#%06x",r<<16|g<<8|b);}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBgqWlJWm6FjfVczWKdNJ1kjSrC4oy80rSNJSUVQ3MKpR0imxsDM1q0m1sLGqSNK1rocrTcxMz8zQ0Faq5OHM1jExNdaBY0xqmPSZPSdOaSwEIcjUMdBRACLukoZGFjoKhpZGOgoU5ugqodTBXAgA)
I could to this all day in every language
[Answer]
# [R](https://www.r-project.org), 20 bytes
```
\(...)rgb(...,m=255)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhZbYjT09PQ0i9KTQLROrq2RqakmROrm2jQNAx0FQyNzHQWQqLKCgoKunYKygYF5WloaV5qGIVASiMASCjBJQxAEShqZmOoomBgDtULkQZJppkZJBkZASXMjiFZjE4SkiYWBoYUZF9hOEEI1FgxAxpqagl0DcxLYWDCAOHrBAggNAA)
Somehow, when I first posted this answer, I managed to overlook the linked related challenge, where it was clearly pointed out that R has a built-in for this specific task...
My original non-built-in solution:
# [R](https://www.r-project.org), 38 bytes
```
cat("#",sprintf("%02x",scan()),sep="")
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGCpaUlaboWN9WSE0s0lJSVdIoLijLzStI0lFQNjCqA3OTEPA1NTZ3i1AJbJSVNiOqVBgqGRuYKRqamED7MFAA)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 19 bytes
```
->*v{?#+"%02x"*3%v}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf106rrNpeWVtJ1cCoQknLWLWs9n@BQlq0oaGOkZGOsXEsF4hnoGNoZK5jZGoa@x8A "Ruby ‚Äì Try It Online")
[Answer]
# JavaScript (ES6), 49 bytes
Not the right tool for the job.
Expects `[r,g,b]`.
```
a=>'#'+a.map(x=>(x>>4&&'')+x.toString(16)).join``
```
[Try it online!](https://tio.run/##ZczRCoMgGIbh812FEKTSZmrWOsmb2OEY5LaKomlUjO6@ZcMO6v/hO3p4G/VVw6uvu/GizbuYy2xWmYQeDBT5qA5NmUSTlML3IcTBREZzG/taV4glGJPG1DrP55fRg2kL0poKlegOAD0DNw@MQRgCj653OlBm1X82yuzvKRfxokRkKXe0jPmT8j29cotslUXCUZFSliaHarxU3WzV9eYf "JavaScript (Node.js) ‚Äì Try It Online")
---
# JavaScript (ES6), 53 bytes
Expects `r,g,b`.
```
(r,g,b)=>'#'+(r+256<<16|g<<8|b).toString(16).slice(1)
```
[Try it online!](https://tio.run/##XcxBDoMgEIXhfU9B0oUQrTII1AX2Ej2BWiU2Rho0XXl3KlY2zCRv9eV/N99m6ez4WW@zefVuqB22mc5aUj@Sa5JimzIhlQK5aaWqrSX5ap6rHWeNQZJ8mcaux0BcZ@bFTH0@GY0HjBDNUBhCUFGgKz3uEkPw5j8Bgv8IMi52w0sP2QkHwVrKInhnnvgilPyEvKJQybgo9mKYUDzO/QA "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `s`, 7 bytes
```
H2‚Ü≥‚Ä∫\#p
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBcyIsIiIsIkgy4oaz4oC6XFwjcCIsIiIsIlswLCAxMjcsIDI1NV1cblsxLCAxLCAxXVxuWzI0NSwgNDMsIDJdIl0=)
The benefits of string padding. And flags. Helps not be beaten by half a byte :p
## Explained
```
H2‚Ü≥‚Ä∫\#p
H         # Convert each item in the input to hexadecimal
 2‚Ü≥‚Ä∫      # append 0s until each string is of length 2
    \#p   # and prepend a "#" 
          # the s flag joins the top of the stack into a single string
```
[Answer]
# [Excel](https://www.microsoft.com/en-us/microsoft-365/excel), ~~31~~ 29 bytes
-7 bytes thanks to [Dominic van Essen](https://codegolf.stackexchange.com/users/95126/dominic-van-essen)
-2 bytes thanks to [Taylor Alex Raine](https://codegolf.stackexchange.com/users/61846/taylor-alex-raine)
```
="#"&CONCAT(DEC2HEX(0&A1#,2))
```
Where `A1` contains the following: `={0,127,255}`.
[![enter image description here](https://i.stack.imgur.com/1DNzj.png)](https://i.stack.imgur.com/1DNzj.png)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
‚Äù#2√òh·πó·ªã@‚Äò
```
A full program that accepts a list of integers from \$[0,255]\$ and prints the resulting hexadecimal string.
**[Try it online!](https://tio.run/##ASgA1/9qZWxsef//4oCdIzLDmGjhuZfhu4tA4oCY////WzI0NSwgNDMsIDJd "Jelly ‚Äì Try It Online")**
...a fair bit shorter than the naive approach of a monadic Link like `+‚Åπb‚Å¥·∏ä‚Ç¨‚Äò·ªã√òh‚Äù#;` which comes in at 13 bytes - [TIO](https://tio.run/##ATIAzf9qZWxsef//K@KBuWLigbThuIrigqzigJjhu4vDmGjigJ0jO////1syNDUsIDQzLCAyXQ).
### How?
```
‚Äù#2√òh·πó·ªã@‚Äò - Main Link: list of integers, Colours
‚Äù#        - '#' character
            ... the chaining of `nilad nilad nilad` (‚Äù#2√òh)
                forces this to be printed to STDOUT with no trailing character(s)
  2       - two
   √òh     - hexadecimal characters -> "0123456789abcdef"
     ·πó    - Cartesian power -> ["00","01",...,"ff"]
        ‚Äò - increment (Colours) (vectorises)
       @  - with swapped arguments:
      ·ªã   -   index into
          - implicit, smashing print
```
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 7.5 bytes (15 nibbles)
```
"#"+.$&"0"2hex
```
```
"#"+.$&"0"2hex
    .           # map over
     $          # each number in the input
           hex  # converting it to hexadecimal
      $         # and justifying it
          2     # to two characters wide
       "0"      # using "0" as filler,
   +            # then, flatten this list
"#"             # and prepend a "#" character.
```
[![enter image description here](https://i.stack.imgur.com/lWMfa.png)](https://i.stack.imgur.com/lWMfa.png)
[Answer]
# [Python 3](https://docs.python.org/3/), 20 bytes
```
lambda x:"#"+x.hex()
```
[Try it online!](https://tio.run/##JYrbCgIhFEXfz1ccphclibwxMDB/0otDDgpmIlb69WYTLDabxUqtuGeUfV9vPZjHdjdYl@k0nevF2Upo/zgfLPIFsKz2bQLxMb0KoRQwZR8L2cnWijU5m0YKpbRfGXIxMxRaAx9/AEJphkoOCbP4O6lglD9glEd@zBc "Python 3 ‚Äì Try It Online")
Takes input as a `bytearray`.
Test bed borrowed from @xnor.
[Answer]
# [CP-1610](https://en.wikipedia.org/wiki/General_Instrument_CP1600) machine code, 34 DECLEs1 = 42.5 bytes2
*1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.*  
*2. This routine is 34 DECLEs long, i.e. 340 bits. As per the exception described in [this meta answer](https://codegolf.meta.stackexchange.com/a/10810/58563), the score is **42.5 bytes**.*
A routine expecting a pointer to three bytes in **R3** and writing the result at **R4** (in white, assuming ColorStack mode).
### Test code
```
    |           |        ROMW    10            ; 10-bit ROM
    |           |        ORG     $4800         ; map the program at $4800
    |           |
4800|001        |        SDBD                  ; set up an ISR for minimal
4801|2B8 030 048|        MVII    #isr,   R0    ; STIC initialization
4804|240 100    |        MVO     R0,     $100
4806|040        |        SWAP    R0
4807|240 101    |        MVO     R0,     $101
    |           |
4809|002        |        EIS                   ; enable interrupts
    |           |
480A|001        |        SDBD                  ; R4 = BACKTAB pointer
480B|2BC 000 002|        MVII    #$200,  R4
480E|001        |        SDBD                  ; R3 = pointer to test cases
480F|2BB 01E 048|        MVII    #test,  R3
    |           |
4812|004 148 040|loop    CALL    rgb           ; invoke our routine
    |           |
4815|2FC 00D    |        ADDI    #13,    R4    ; advance to the beginning
    |           |                              ; of the next line
4817|001        |        SDBD
4818|37B 030 048|        CMPI    #done,  R3    ; done?
481B|225 00A    |        BLT     loop
    |           |
481D|017        |        DECR    R7            ; loop forever
    |           |
481E|000 07F 0FF|test    DECLE   0, 127, 255   ; #007fff
4821|001 001 001|        DECLE   1, 1, 1       ; #010101
4824|0F5 02B 002|        DECLE   245, 43, 2    ; #f52b02
4827|048 001 086|        DECLE   72, 1, 134    ; #480186
482A|000 000 000|        DECLE   0, 0, 0       ; #000000
482D|0FF 0FF 0FF|        DECLE   255, 255, 255 ; #ffffff
    |           |done
    |           |        ;; ------------------------------------------- ;;
    |           |        ;;  ISR                                        ;;
    |           |        ;; ------------------------------------------- ;;
    |           |isr     PROC
4830|240 020    |        MVO     R0,     $0020 ; enable display
4832|280 021    |        MVI     $0021,  R0    ; colorstack mode
    |           |
4834|1C0        |        CLRR    R0
4835|240 030    |        MVO     R0,     $0030 ; no horizontal delay
4837|240 031    |        MVO     R0,     $0031 ; no vertical delay
4839|240 032    |        MVO     R0,     $0032 ; no border extension
483B|240 028    |        MVO     R0,     $0028 ; black background
483D|240 02C    |        MVO     R0,     $002C ; black border
    |           |
483F|0AF        |        JR      R5            ; return from ISR
    |           |        ENDP
```
### Routine ($4840-$4861)
```
    |           |        ;; ------------------------------------------- ;;
    |           |        ;;  our routine                                ;;
    |           |        ;; ------------------------------------------- ;;
    |           |rgb     PROC
4840|275        |        PSHR    R5            ; push the return address
    |           |
4841|2B8 01F    |        MVII    #$1F,   R0    ; draw the '#'
4843|260        |        MVO@    R0,     R4
    |           |
4844|2BA 003    |        MVII    #3,     R2    ; repeat 3 times
    |           |
4846|298        |@@loop  MVI@    R3,     R0    ; R0 = byte to display
4847|00B        |        INCR    R3            ; advance R3
4848|004 148 054|        CALL    @@hexa        ; draw the upper nibble
484B|04C        |        SLL     R0,     2     ; shift the lower nibble
484C|04C        |        SLL     R0,     2
484D|004 148 054|        CALL    @@hexa        ; draw it
4850|012        |        DECR    R2            ; loop?
4851|22C 00C    |        BNEQ    @@loop
    |           |
4853|2B7        |        PULR    R7            ; return
    |           |
4854|081        |@@hexa  MOVR    R0,     R1    ; copy R0 into R1
4855|3B9 0F0    |        ANDI    #$F0,   R1    ; isolate the upper nibble
4857|2F9 10F    |        ADDI    #$10F,  R1    ; add the offset for '0'
    |           |                              ; and set the lower nibble
    |           |                              ; so that we write in white
4859|379 19F    |        CMPI    #$19F,  R1    ; if greater than '9' ...
485B|206 002    |        BLE     @@print
    |           |
485D|2F9 270    |        ADDI    #$270,  R1    ; ... advance to 'a'
    |           |
485F|061        |@@print SLR     R1            ; right-shift to get the
    |           |                              ; final value
4860|261        |        MVO@    R1,     R4    ; write it
4861|0AF        |        JR      R5            ; return
    |           |        ENDP
```
### Output
[![output](https://i.stack.imgur.com/qJnOS.gif)](https://i.stack.imgur.com/qJnOS.gif)
*screenshot from [jzIntv](http://spatula-city.org/%7Eim14u2c/intv/)*
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~86 84 76 75 69 65 61~~ 57 bytes
```
b;main(c){for(;~scanf("%d",&c);printf("#%02X"+!!b++,c));}
```
[Try it online!](https://tio.run/##S9ZNT07@/z/JOjcxM08jWbM6Lb9Iw7quODkxL01DSTVFSUctWdO6oCgzrwTIV1Y1MIpQ0lZUTNLW1knW1LSu/f/fQMHQyFzByNT0X3JaTmJ68X/dcgA "C (gcc) ‚Äì Try It Online")
* Kudos to @mousetail for shaving 2 bytes (from 86 to 84)
* Kudos to @corvus\_192 for shaving 4 bytes (from 65 to 61)
* Kudos to @jdt for shaving 4 bytes (from 61 to 57)
### Ungolfed with comments, courtesy of @jdt:
# [C (gcc)](https://gcc.gnu.org/), 326 bytes
```
// all global and static variables are initiated to 0. 
int b = 0; 
main(int c)
{
    // scanf will retun -1 when done. ~-1 = 0
    while (~scanf("%d",&c)) 
    {
	// Here we do some pointer arithmetic.
        char* format = "#%02X";
        printf(format + (b != 0) , c);
        // now we increment b
        b++;
    }
}
```
[Try it online!](https://tio.run/##PU9LboMwEF3Xp3ilSgQlHxIp6iLqvkfodjADWDJ2ZNx6ESVHLx1oldnNvO/obaf1NO33IGvRWV@TBbkGY6RoNL4pGKotj6DAMM5EQ5EbRI9qB2VcRI13VGcoNZBx@XzRhboqyIjtqMm1SEbcA8cvh@0BqWeHxjve4S6ryBd26o1l5PdFkmerJtusdVFgAa/qSdw@WFokFjFGPzAuXvI4SDkT@4Gl8W5hz6N7Cq9ofRgoSkb2sqqOn9n5gV@CaNv8n1Air/EsVQps5IGzevAk1vk0pxqnAw88//xA67L8s7yp2zRVOBzfcDydfnRrqRunbfoF "C (gcc) ‚Äì Try It Online")
[Answer]
# [Python](https://www.python.org), ~~38~~ 23 bytes
* -1 byte thanks to @py3\_and\_c\_programmer
```
lambda*x:"#"+"%02x"*3%x
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwdI0BVuFmKWlJWm6FjtyEnOTUhIVtCqslJSVtJVUDYwqlLSMVSsg0jctC4oy80o00jSMTE11oFhTkwsmamhkARY1QxIz0AFCTU2IAQsWQGgA)
[Answer]
# [Perl 5](https://www.perl.org/) + `-pl043`, 19 bytes
```
$\.=unpack H2,chr}{
```
[Try it online!](https://dom111.github.io/code-sandbox/#eyJsYW5nIjoid2VicGVybC01LjI4LjEiLCJjb2RlIjoiJFxcLj11bnBhY2sgSDIsY2hyfXsiLCJhcmdzIjoiLXBsMDQzIiwiaW5wdXQiOiIyNDVcbjQzXG4yIn0=)
## Explanation
Uses the commandline flag `-l043` to prepopulate `$\` with `'#'` and for each input line, appends the result of `unpack`ing the number to `H2` (`0`-padded hex representation).
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 49 bytes
```
.+
$*
%`^(.{16})*(.)*
$#1¬∂$#2
T`d`l`..
.\B|¬∂
^
#
```
[Try it online!](https://tio.run/##K0otycxL/K@qEZyg819Pm0tFi0s1IU5Dr9rQrFZTS0NPU4tLRdnw0DYVZSOukISUhJwEPT0uvRinmkPbuLjiuJT//zfQMTQy1zEyNeUy1AFCLiMTUx0TYx0jLnMjEN/YhMtABwi5gCp0oBgA "Retina 0.8.2 ‚Äì Try It Online") Takes input on separate lines but link is to test suite that splits on commas for convenience. Explanation:
```
.+
$*
```
Convert to unary.
```
%`^(.{16})*(.)*
$#1¬∂$#2
```
Divmod by `16`, resulting in a list of six integers from `0-15`.
```
T`d`l`..
```
Adjust `10-15` by transliterating `0-5` to `a-f`.
```
.\B|¬∂
```
Remove the leading digit from integers that used to be above `9` and join all of the digits together.
```
^
#
```
Prefix a `#`.
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 25
```
printf \#${f=%02x}$f$f $@
```
[Try it online!](https://tio.run/##S0oszvhfnpGZk6pQlJqYYq2Qks9VnFqioKuroBLkGuAT@b@gKDOvJE0hRlmlOs1W1cCoolYlTSVNQcXhf2pyRj5XSn5e6n8DBUMjcwUjU1MuQwUg5DIyMVUwMVYw4jI3AvGNTbgMFICQC6hCAYoB "Bash ‚Äì Try It Online")
[Answer]
# Java 8, ~~41~~ 40 bytes
```
(r,g,b)->"".format("#%06x",r<<16|g<<8|b)
```
-1 byte thanks to *@Arnauld* by porting [@mousetail's C answer](https://codegolf.stackexchange.com/a/254095/52210).
Output in lowercase. Could be in uppercase by replacing the `x` with `X`.
[Try it online.](https://tio.run/##ZVDLbsIwELzzFautKtmyE5GQQFXS/kG59Fj1YAfjhiZO5BjUqvDtqRN8AKGVR9rZ13j24iii/fZ7KGvR9/AmKvM3A6iMU3YnSgWbMQV4d7YyGkriK2D5iHpCSde@4Tzz0DvhqhI2YOBlIJZrLmn0ihjvWtsIR/Dhcb78QW6LIlmedFE8nSQd1uNod5C1Hw0bjm21hcZLIZezH5@CXmQ41TuScB/T2UCkWc6zBU@vuVU6di2ya27Ok3TF0zy/JX3cbMtzHt7d3yZlU9e9D8Go396pJm4PLu68dlcbYhlyZHpCyfAZGQLGVnXKm5LMI4LIrK9LGtfKaPdFKGUmLoOFQcR5@Ac)
**Explanation:**
```
(r,g,b)->             // Method with three integer parameters and String return-type
  "".format("#%06x",  //  Return a String with a format as:
             #        //   A leading hash "#"
              %  x    //   And an integer converted to a hexadecimal value
                6     //   of size 6
               0      //   with potential leading 0s if it's smaller than 6
                      //  Where the integer is:
    r<<16             //   Input `r` bitwise right-shifted by 16
    |                 //   Bitwise-ORed with
    g<<18             //   Input `g` bitwise right-shifted by 8
    |                 //   Bitwise-ORed with
    b)                //   Input `b` as is
```
[Answer]
# [Raku](https://raku.org), ~~26~~ 25 bytes
```
{printf '#'~'%02x'x 3,@_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/uqAoM68kTUFdWb1OXdXAqEK9QsFYxyG@9n@agoGOoZG5jpGpqTVXmoKhDhCCGEYmpjomxjpGILa5EUjU2ATENtABQrACU1MdKLb@DwA)
*-1 byte thanks to [@IsmaelMiguel](https://codegolf.stackexchange.com/users/14732/ismael-miguel)*
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 12 bytes
```
"#",`hex@`c$
```
[Try it online!](https://ngn.codeberg.page/k#eJwtilEKgCAQBf89xWMTMjCyVQlciI4iRNEB/BCiu2cQw3wMzJmoI5uvo25510qVZBxmXsAxyoyGcIgIHiwLf+2DODSkHfgdVHbpNgSaRq91HSxhXEH23OrTlxdB3hVN)
Takes input as a list of 3 integers.
``c$` Cast to string (bytes).  
``hex@` Format bytes as hexadecimal values.  
`"#",` Prepend a `#`.
[Answer]
# [Julia 1.0](http://julialang.org/), 36 bytes
```
~x="#"*(string.(x,base=16,pad=2)...)
```
[Try it online!](https://tio.run/##TdDNagMhEAfwc32KP@aiRRY1azYULBT6FiEH013DtpIuqwF7yatvrUnajjCXn/PBvJ/D6FRelku2dEUfWUzzeDo2LIuDi4NVGzG53mreNA1fSG9fx7fEyMNOCgBKdwLamD3sM@hKys57T0VhVbkm4M7q51XWrRFo18X1L3ujD1JX7rS4V6/bG7dbqbabynX2Nf01r3Ftbkzd6v9qvkZhTsg8xHNIERYuBHbJsBb9Lu/hP2dkjCd8DF@R9bz8nco1EqMvISANsRRNLsZyoCdQgVsjTpZv "Julia 1.0 ‚Äì Try It Online")
-1 byte thanks to @amelies: Replace `prod` with `*`. A single operator can behave as both a monad and dyad in Julia!
[Answer]
# C#, 31 bytes
```
(r,g,b)=>$"#{r:X2}{g:X2}{b:X2}"
```
[Answer]
# [><> (Fish)](https://esolangs.org/wiki/Fish), 102 bytes
Since this challenge is super easy I wanted to try some esolangs.
Takes input as raw byte values.
```
"#"o03i:&82*,01.
 :9)?v68*+o.
v+"W"<;
o14&82*%01.
\.05i:&82*,01.
 06&82*%01.
 07i:&82*,01.
 52&82*%01.
```
[See it in action (animated)](https://mousetail.github.io/Fish/#%7B%22text%22%3A%22%5C%22%23%5C%22o03i%3A%2682*%2C01.%5Cn%20%3A9%29%3Fv68*%2Bo.%5Cnv%2B%5C%22W%5C%22%3C%3B%5Cno14%2682*%2501.%5Cn%5C%5C.05i%3A%2682*%2C01.%5Cn%2006%2682*%2501.%5Cn%2007i%3A%2682*%2C01.%5Cn%2052%2682*%2501.%22%2C%22input%22%3A%22i%245%22%2C%22stack%22%3A%22%22%2C%22mode%22%3A%22numbers%22%7D) - [Try it online](https://tio.run/##S8sszvj/X0lZKd/AONNKzcJIS8fAUI9LwcpS077MzEJLO1@Pq0xbKVzJxpor39AEpEAVpCBGz8AUWb2BGVxKwcAcWcbUCCbz/39iUjIA)
## Explanation:
This is a function that prints a single hexadecimal number:
```
 :9)?v68*+o.
v+"W"<
o
\.
```
Basically, check if the number is more than 9, if so add "W" ("W"+9 = 'a'), and print it. Otherwise add 6\*8='0'. In both cases we use . to "return" from the function.
The function wraps around the left margin since this is "dead space". Since you can't jump to the leftmost
The rest of the code is either of these 2 statements repeated:
```
07i:&82*,01.
```
First 2 values are the return pointer, it's where the function will return. Then we take input and copy 1 value to the register. We divide by 16 (2\*8), then push the start address of the print function, and call it with .
The other variant is very similar:
```
14&82*%01.
```
Again 14 is the return value. We take the value form the register, but this time modulo it by 16. Again we call the function at 01.
Notice the last function returns to 52, which is the location of the stray `;` (right of the `<` inside the function) that exits the program.
# [><>](https://esolangs.org/wiki/Fish), 119 bytes
```
"#"oi:&82*,:9)"'"*+"0"+o&82*%:9)"'"*+"0"+oi:&82*,:9)"'"*+"0"+o&82*%:9)"'"*+"0"+oi:&82*,:9)"'"*+"0"+o&82*%:9)"'"*+"0"+o;
```
[Try it online!](https://tio.run/##S8sszvj/X0lZKT/TSs3CSEvHylJTSV1JS1vJQEk7HySiiiJCTVXW//8nJiUDAA "><> ‚Äì Try It Online")
Alternate solution that uses just 1 line.
[Answer]
# x86-32 machine code, 28 27 bytes
```
"\x6a\x23\x58\x99\xaa\xb1\x1c\xac\xd3\xc0\x3c\x0a\x1c\x69\x2f\xaa"
"\xd3\xe8\x30\xce\x75\xf4\x42\x7b\xee\x88\x27"
```
#### Requirements:
* SS:ESP-4 -> 4 bytes of writable memory
* DS:ESI -> 3 bytes of readable memory containing `r`, `g`, `b`
* ES:EDI -> 8 bytes of writable memory to receive NUL-terminated ASCII string (`"#XXXXXX\0"`)
* Direction Flag clear
#### In assembly language:
```
6a 23           push 23h  ; "#"
58              pop eax
99              cdq
aa              stosb
b1 1c           mov cl, 1Ch
__byteloop:
ac              lodsb
d3 c0           rol eax, cl
__nibbleloop:
3c 0a           cmp al, 0Ah  ; someone's old trick for converting a nibble to hex
1c 69           sbb al, 69h
2f              das
aa              stosb
d3 e8           shr eax, cl
30 ce           xor dh, cl
75 f4           jnz __nibbleloop
42              inc edx
7b ee           jnp __byteloop
88 27           mov [edi], ah
```
[Answer]
# Scratch, 235 Bytes
[![https://scratch.mit.edu/projects/836662188/editor/](https://i.stack.imgur.com/w2GIg.png)](https://i.stack.imgur.com/w2GIg.png)
[Link to the editor for the script](https://scratch.mit.edu/projects/836662188/editor/)
Source:
```
when gf clicked
set[I v]to(0
set[X v]to[#
repeat(3
change[I v]by(1
set[X v]to(join(x)(join(letter(((item(I)of[C v])-((item(I)of[C v])mod(16)))+(1))of[0123456789ABCDEF])(letter(((item(I)of[C v])mod(16))+(1))of[0123456789ABCDEF
end
say(X
```
It was exhausting to put this into plain text, so I'm not golfing this down YET.
[Answer]
# [Bitcoin Cash Script (BitAuth IDE)](https://alpha.ide.bitauth.com/), 601 bytes, 93 bytes as raw bytecode
```
// Input
<127>
<0>
<255>
// Program
OP_DUP
<16> OP_MOD
OP_SWAP
<16> OP_DIV
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_SWAP
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_CAT
OP_ROT
OP_DUP
<16> OP_MOD
OP_SWAP
<16> OP_DIV
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_SWAP
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_CAT
OP_ROT
OP_DUP
<16> OP_MOD
OP_SWAP
<16> OP_DIV
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_SWAP
OP_DUP <9> OP_GREATERTHAN
OP_IF
<7> OP_ADD
OP_ENDIF
<48> OP_ADD
OP_CAT
OP_ROT
OP_CAT OP_CAT
<'#'> OP_SWAP OP_CAT
// Output string left on stack
// We can also execute it all using raw bytecode
OP_DROP // Clean up
// Input
<127>
<0>
<255>
/// Program
0x7660977c60967659a0635793680130937c7659a0635793680130937e7b7660977c60967659a0635793680130937c7659a0635793680130937e7b7660977c60967659a0635793680130937c7659a0635793680130937e7b7e7e01237c7e
```
[Try it online!](https://ide.bitauth.com/import-template/eJztlFFv0zAQx7-KZZD20jVuSuOlqiaFprA-bIm6jj1QVLnusQYSJ4ovY2jqd-fsMDQkxBMSPPDi8_3u_z_rJNuP_KXVB6gUn_IDYmOnQbArUHV4GOq6CvqiDRwAg4VWWNTmFKFqSoVwei-GvWT4ydaGD_gerG6LxqmoJQGjKqDdDZmxhD0R1wcLsHz6eBzwXu4St1WoD9tG7V363XndU5YrZ-7lhIOALU3T4cbMRqE8pyDcEk4mFKiYt_Vdq6qNyfJtepM7WXTOKLnMUg-vb5NnNF2-e5KyWezR29UiWS9W64vkypeWb0gufSlJ-x6Lq9TTV2c_4b71n-o2T9Y-rrL1_2n-8WkoZ094dvLixIvdkT8oXc2sQ7q4zGJbmDtWwkdktaFU6c8b4xW3wLQyTJW2ZvAAukNgBVJess46U6u-sN1XBF3voZ9mleWMnPMSyNg1vs3vHsizFyIeZBSJWEpNaySjSaxENJ7IeBydidFYxGOpf0lB7v6KEySIUegUwI_uD-mapm6Rfpfpe_56frENRSi2YsI_DPg9tNZ_RuL4DS6ufJw=)
[Answer]
# [Factor](https://factorcode.org/), 25 bytes
```
[ "#%02x%02x%02x"printf ]
```
[Try it online!](https://tio.run/##S0tMLskv@h8a7OnnbqWQll@Um1hSkpmXrpCdWpSXmqNgzWVkYqpgYqxg9D9aQUlZ1cCoAoaVCooy80rSFGL/Jyfm5PwHAA "Factor ‚Äì Try It Online")
[Answer]
# [Clojure](https://clojure.org/), 30 bytes
```
#(format"#%02x%02x%02x"% %2%3)
```
[Try it online!](https://tio.run/##VU5BCsIwELznFUtLIIEKyTaxBcGPhBysbUSprcYK/j6mqVacnb3sMLNz7MfL03eBtZ0DF3LmRn89TFlOBb6@m1GgSEseOGHt@Ojuxng4QWPBECMKkFgVgFpbANht9pALUTnniJFRi5zvsGpyHmJQ6QJUGY121ZzGRiAxFS7GUv00VQtZb9O/mf@ZCTFT61Tk02bJTCDWEnbz52HqB2AOUn/OeXgD "Clojure ‚Äì Try It Online")
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 28 bytes
```
h¬¶‚ü®)‚ÇµHE¬§\‚ü©¬¶¬¶$¬¶‚ü®0¬§+3‚äÇ·∏•‚ü©¬¶$'#¬§+
```
[Try it online!](https://tio.run/##S0/MTPz/P@PQskfzV2g@atrq4XpoScyj@SsPLTu0TAUsanBoibbxo66mhzuWgsVV1JWBIv@jzY0UDBUMjU1iH7VN/A8A "Gaia ‚Äì Try It Online")
28 bytes may seem like a lot of bytes until you discover that there is no "convert a number to hexadecimal as a string" built-in in Gaia. Why was "convert to base 16 as a list of digits" the thing that got added and not to string?
Using a similar algorithm to the 05AB1E and MathGolf answers would probably be longer.
Gaia does not have list input in the input box, so this is a function submission.
## Explained
```
h¬¶‚ü®)‚ÇµHE¬§\‚ü©¬¶¬¶$¬¶‚ü®0¬§+3‚äÇ·∏•‚ü©¬¶$'#¬§+
h¬¶                          # Convert each number to base 16 (list of digits)
  ‚ü®      ‚ü©¬¶¬¶                 # To each digit in each number:
   )                        #  Increment it to account for 1-indexing
    ‚ÇµHE                     #  and index it into the string "0123456789ABCDEF"
       ¬§\                   #  Remove some extra junk from the stack
           $¬¶               # Convert each list to a single string
             ‚ü®      ‚ü©¬¶       # To each hex string:
              0¬§+           #  Prepend 0
                 3‚äÇ         #  repeat the first character of the string enough times to make it at least length 3
                   ·∏•        #  remove the leading 0
                     $'#¬§+  # join into a single string and prepend the # character
```
[Answer]
# [Sequences](https://github.com/nayakrujul/sequences), \$22 \log\_{256}(96) \approx 18.1\$ bytes
```
"#"H3x{\016iB2jH}g""JF
```
### Explanation
```
"#"H3x{\016iB2jH}g""JF
"#"H                    // Push "#" to the list
    3x{         }       // Repeat 3 times:
           i            //   Get a numeric input
         16 B           //   Convert to hexadecimal
       \0    2j         //   Fill with 0s on the left up to 2 characters 
               H        //   Append to the list
                 g      // Get the list
                  ""J   // And join by ""
                     F  // Output the joined string
```
### Screenshot
[![Screenshot](https://i.stack.imgur.com/JwQTM.png)](https://i.stack.imgur.com/JwQTM.png)
]