The fundamental task of education is to cultivate morality and cultivate people. How to integrate ideological and political elements into classroom teaching is discussed in this article. Taking the teaching of Fermat’s theorem as an example, how to apply current educational technology to arouse students’ interest, stimulate learning enthusiasm, and achieve the goal of leading while imparting knowledge.