NSW maths teacher loses out on $1m prize