Algorithm program 3