結果 : algorithm for nested loop in python