algorithm ,just for funl