Large Prime Number

There is a question in which I need to find if a no is prime or not, but range of no is 10^18… What’s the logic behind it?

check upto sqrt(n) then complexity will be reduced