J.P. Morgan interview question

Basic algorithms questions. Such as integer counting.