Hello Mollishree Soor,

It will yield a null result, since we stop with the sqrt of the number n(5), which is 2. The factor we start with also is 2.

It will check whether the number(5) is divisible by 2. It doesn’t, so the factor 2 will not be added to the result. And it will return an empty set.

The important line is if(n%x ==0), only when a number is divisible by another number. We are adding it to the result set.

Thanks, let me know whether that clears the doubt for you.

Code -> Understand-> Repeat is my motto. I am a Data Engineer who writes about everything related to Data Science and Interview Preparation for SDE.

Code -> Understand-> Repeat is my motto. I am a Data Engineer who writes about everything related to Data Science and Interview Preparation for SDE.