Deepak and primes 2 doubt

please provide me with the correct code for this question

hello @rohit_1906

check this -> https://ide.codingblocks.com/s/187733