For this Question: Given an integer N, find the closest prime number to N. If there are multiple print the smaller one.The input contains a single integer N.

Constraints:
1 <= N <= 1000000000Print the closest prime to N.Sample Input 1
12

Sample Output 1
11

Explanation: Closest prime to 12 is 11 and 13 smaller of which is 11.

Sample Input 2
17

Sample Output 2
17

Explanation: Closest prime to 17 is 17., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
















		if(n==1){
   			 System.out.println(2);
		}else{
		 int after = afterPrime(n);
         int before = beforePrime(n);
        if(before>after){
			System.out.println(n+after);
		}
		else{System.out.println(n-before);}
    }

	}

	public static boolean isPrime(int n)
    {
        int count=0;
        for(int i=2;i*i<n;i++)
        {
            if(n%i==0)
                count++;
        }
        if(count==0)
            return true;
        else
            return false;
    }
    public static int beforePrime(int n)
    {
        int c=0;
        while(true)
        {
            if(isPrime(n))
                return c;
            else
            {
                n=n-1;
                c++;
            }
        }
    }
    public static int afterPrime(int n)
    {
        int c=0;
        while(true)
        {
            if(isPrime(n))
                return c;
            else
            {
                n=n+1;
                c++;
            }
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?