We check that 2 is a quadratic nonresidue mod 541 using Euler's Criterion:
2.powermod((541-1)/2,541)
We could also use the kronecker command to compute the appropriate Legendre symbol:
kronecker(2,541)