I assume you want a scaled version of the inverse colour. For example, you might want the shadow to be at least in the 0-128 range and not in the 0-255 range? Which would obviously just divide by 2. Do you want the divisor to be scaled as well depending on the brightness of the original colour?
EDIT: Oops just reread your post, ignore this.
So you want the complementary colour not the inverse?
Complement changes each component of a color to a new value based on the sum of the highest and lowest RGB values in the selected color.
Add the lowest and highest RGB values of the current color, and then subtract the value of each component from that number to create new RGB values.
For example, suppose you select a color with an RGB value of 102 for red, 153 for green, and 51 for blue. Add the high (153) and low (51) values, to end up with a new value (204). Each of the RGB values in the existing color is subtracted from the new value to create new complementary RGB values: 204 – 102 (the current red value) = 102 for the new red value, 204 – 153 (green) = 51 for the new green value, and 204 – 51 (blue) = 153 for the new blue value.