What is Happening at Primes here?

while(p*p <=m){

if(m%p == 0){

int cnt = 0;

		while(m%p == 0){
			cnt++;
			m = m/p;
		}
		ans =ans *(cnt-1);
	}
	//Go to Next Position
	i++;
	p = primes[i];
}

hello @JaveedYara
What u want to ask? pls elaborate

why is m Mod p being divided and being checked?

@JaveedYara
for p to be a factor of m it should divide m right?
that is why we are checking it using m%p if m%p gives 0 that means p is factor of m

and what about ans variable there?

and p = primes[i] what does this do?

primes vector is holding prime numbers.
i++;
p=primes[i] ;
is giving use next prime number.

it is holding the overall answer

so why is ans then Getting Multiplied to count-1. Last Doubt. you have been great, Thank you so Much

no it should be cnt+1 in place of cnt-1.

if prime factorisation of number n is written as ->
n=p1^a * p2 ^ b * p3 ^ c … ( where p1 ,p2,p3 are prime number and a,b,c are the respecitve power)

then number of divisors will be (a+1) * (b+1) * (c+1)
that cnt variable is playing the role of a ,b,c

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.