int fi(int n)

{

int result = n;

for(int i=2;i*i <= n;i++)

{

if (n % i == 0) result -= result / i;

while (n % i == 0) n /= i;

}

if (n > 1) result -= result / n;

return result;

}

This code here int the for() loop does n*(1-1/P)… till the square root… I am unable to understand that when it comes out of the for loop we check if n>1 … Now if n>1 how are we sure that n is a prime number…

I visualise this as result*(1-1/P)…=(result-result/Prime)*(1-1/P2)…