Vivek and Factors doubt

I don’t understand the logic behind the line 24 and 25 ,
Check the code here : https://ide.codingblocks.com/s/342950

if the number is prime number then the, none of the number from 2 to sqrt(n) would be factor of n and the number will go inside the, if statement in line 24

Ohk , right thank you!!