This is a solution that works for one input N at a time. Will scale to more N later (tomorrow after ACM and between Mobile App Dev Club.