Decomposing an integer in pieces