Your code will determine if a integer is a prime number or not, but not very efficiently, which might not matter if the prime numbers you're going to test are small.
You can easely optimize your code if you realize that N = Sqrt(N)*Sqrt(N) which means your loop condition would be i<=sqrt(n)
While this optimizes your code it's still not a good solution when you're gonna test big integers. The best algorithm, I know of, for determining whether an integer is a prime or not is the
Miller-Rabin test[
^]
Edit:
I just saw that your code actually isn't correct.
you'll need to initialize
n
ofcourse. and you're saying that n/i == 0 means that n is not a prime, that is not correct. If n%i == 0 then
n
is not a prime. You also have your break outside your if-block so your loop will stop after the first run through.