There are many correct answers. Here is one. Since we are looking for a value that is prime, just keep making r larger until one is found that is prime.
int r = v; while(!Math.isPrime(r)) { r = r + 1; }