The easiest solution I can think of:
Code:

var max_distance = 100;
var distance;
var inverse_dist;

inverse_dist = max_distance - distance;

//Examples:
distance == max_distance => inverse_dist = 0
distance = 20 => inverse_dist = 100 - 20 = 80
distance = 80 => inverse_dist = 100 - 80 = 20



Not sure if thats what you want though.