J.P. Morgan Interview Question

Basic algorithms questions. Such as integer counting.