Hi all would appreciate some help or general advice on changing the following code so as to stop whenever i>sqrt(n). My problem is that n is a integer input from a user so how do I calculate a sqrt of it?
Thanks in advance
Andrew
Code:/*Is n a prime?*/ main() { int i,m,n; m=0; scanf("%d", &n); for (i=2;i<n;i++){ if (n%i==0) m=1; } if (m==0) printf("%d is prime",n); else printf("%d is not prime",n); return 0; }