Q:

A nice algorithm for font-size relative to number of chars and screen width

Ok, so I have a input field with a big font (100px). The thought is that when the user starts writing letters, the font size will lower instead of the phrase moving off screen. 
Its gotta be responsive as well, so some algorighm that includes the screen width would be nice.
What I have now:
var chars = $('#big-search').val();
var w = $(window).innerWidth();

var fz = parseInt($('#big-search').css("font-size"), 10);
console.log(fz);
var nfz = 100-((chars.length/w)*(w*2.2));
if(nfz < 100){
    $('#big-search').css("font-size", nfz+"px")
}

The problem is that it speeds up the lowering of the font size. But it should rather slow it down.
Any thoughts on this?

A:

This did the trick:
var baseFz = 100;
var chars = $('#big-search').val();
var w = $(window).innerWidth();
var nfz = (w/100)*(baseFz/chars.length);

if(nfz <= 100 && nfz >= 20){
    $('#big-search').css("font-size", nfz+"px");
} else if(nfz >= 100){
    $('#big-search').css("font-size", 100+"px");
} else if(nfz >= 20){
    $('#big-search').css("font-size", 20+"px");
}

