Add swap number algorithm