serial algorithm programm