greedy using div and mod to calculate coins without loops