I think it was Polya who said in his book "How to solve it" that one method for approaching a difficult task is to consider a simpler case.
So, try thinking about how you would solve it if you ONLY had 1024MB memory chips.
if i input 7168, how would you figure out how many chips are required? what if i put in 14,336?
once you solve that, add one more size chip, like the 512. then try and solve some made up cases, like 1536 or 7680... then add a third size... eventually
you should see a general solution.
OR, try it will even smaller numbers... what if you only had memory chips that were 1, 2, 4, and 8 ? how would you solve it for a value of 7? for 39?