6for algorithm

6for algorithm