What I'm trying to do is have a user enter a number

have the computer check to see if it is prime number. AND if it is not prime what is the next the next closest prime number. i got the figuring out the prime number part but don't know how to add in the additional info needed (the next closest prime number). Here is what I got so far

if ( n%2 == 0 ) {

# The number is even, so not prime.

}

else {

for ( i = 3; i < sqrt(n); 2++ ) { # Check odd divisors only

if ( n%i == 0 ) {

# The number is not prime.

}

}

}

# The number is prime.

Any ideas

Thanks

Matt