Solve Problem#20 by BF, elegant