shortened code for hackerrank print s n solution