Checking number is prime or not

PHOTO EMBED

Thu Apr 06 2023 14:22:04 GMT+0000 (Coordinated Universal Time)

Saved by @afridi #java

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		System.out.println("Hello World");
		int n=52;
		for(int i=2;i<=Math.sqrt(n);i++){
		    if(n%i==0){
		        System.out.print("YES");
		        System.exit(1);
		    }
		    
		      
		}
		
		        System.out.println("NOT");
		    
	}
}
content_copyCOPY

Help of this code i can find no is prime or not in O(log(n)) time