Verisign interview question

programming logic