AMC8数学竞赛中有这样一套题目:
大意是一个正整数,用7除余数为2。请问,这个数如果乘以9再用7除,余数是多少?
什么是模运算?
关于模运算,GPT的解释是:
Alright, let's dive into the magical world of modular arithmetic! Imagine you're trapped in a never-ending loop of a clock. It's always 12 hours, no matter how many times you spin around. That's essentially what modular arithmetic is like—numbers keep looping back after hitting a certain value called the modulus.
大意是取模运算就像一个不断循环的时钟,随着时间增长,小时数也不断从0、1、到11,但是到了12点以后就清零,继续循环时又从1、2等开始。
首先看GPT对上述问题的求解:
上面是GPT的求解,很简洁。如果n模7的余数是2,两边同时乘以9,则9n模7的余数是18,或者说是4。
模运算的加减乘除法则
下面看一下模运算的法则。先看一下GPT的解释: