Western Digital Interview Question

coding question on logic about numbering