printer calculate algoritm