From Rgb to Cmyk
Dyalog APL, 16 15 bytes
1-⊢(÷,255÷⍨⊢)⌈/
1 minus 1-
X divided by ÷
Y, followed by ,
255 dividing 255÷⍨
Y ⊢
, where
X is itself ⊢
(i.e. the list of RGB values), and
Y is the max /⌈
(of the RGB values).
$$ \begin{cases} J = max(R,G,B)\\ C = 1-\frac{R}{J}\\ M = 1-\frac{G}{J}\\ Y = 1-\frac{B}{J}\\ K = 1-\frac{J}{255}\\ \end{cases} $$
TryAPL!
Credits:
∘ -1 byte by ngn.
C#, 88 86 85 84 bytes
(r,g,b)=>{float[]a={r,g,b,1};var j=a.Max();a[3]=j*j/255;return a.Select(x=>1-x/j);};
output for 108,174,106
:
0.3793104
0
0.3908046
0.3176471
Since OP allows function I submitted only the lambda. You can find a running demo on .NetFiddle. I am not a golfer, I post for fun. Also, it is my first answer \o/. Feel free to comment any improvement :)
Kudos to Leaky Nun for the formula.
caveat: it doesn´t work for [0,0,0] (thank you Titus)
Python, 46 bytes
lambda*c:[1-i/max(c)for i in c]+[1-max(c)/255]
Requires input to be floats in Python 2, fairly sure it doesn't in 3.