Why are we computing No%primes[i] and not No%i?

In this solution which was shown in the video, on line 12th why are we doing n%primes[i] and not n%i ??

As we have to check from 2 till sqrt(n) so why are we not doing n%i that is checking with every number till sqrt(n) and doing n%primes[i] that is only checking by prime numbers!?

Hello @rohitmathur.mathur.6 in this we are doing prime[i]*prime[i]<=no because here we are checking for all the devisors of prime number less then route n.
if the number in this range divides the number then it is not the primenumber otherwise it will be the prime number.

Yeah i get it, but couldn’t we have done i*i<=n and n%i instead of n%primes[i] ?

@rohitmathur.mathur.6 then what will be the benefit of finding the prime numbers then?by using prime numbers we are optimising our code:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.