Step through the algorithm:

stage 1 2005 pennies 1 to C, 1002 to J, leaves 1002

stage 2 1002 pennies 501 to M, leaves 501

stage 3 501 pennies 1 to C, 250 to J, leaves 250

stage 4 250 pennies 125 to M, leaves 125

stage 5 125 pennies 1 to C, 62 to J, leaves 62

stage 6 62 pennies 31 to M, leaves 31

stage 7 31 pennies 1 to C, 15 to J, leaves 15

stage 8 15 pennies 1 to C, 7 to J, leaves 7

stage 9 7 pennies 1 to C, 3 to J, leaves 3

stage 10 3 pennies 1 to C, 1 to J, leaves 1

stage 11 1 pennies 1 to C, 0 to J, leaves 0

Now do some adding:

C gets: 8 pennies

M gets: 657 pennies

J gets: 1340 pennies

I'm pretty sure that there is a neat direct way of doing this, but the question looks to me as though it is meant to introduce you to the idea of an algorithm, so I have solved it by tracing the process

RonL