A physical approach to Goldbach's conjecture and Fermat's last theorem