示例:3 的幂
让我们来看看一个数在模运算下的幂。我们将查看

我们将在一个素数 模下进行计算。首先,我们将选择 。我们可以计算每个数,然后进行模运算,例如


但是,直接从 计算 会更快,如下所示








很明显,这个模式是重复的。这是因为 . 即使不做计算,也很清楚这个模式必须在某个地方重复。对于 ,最多有 7 种不同的可能数字,所以如果我们计算 ,一定会在里面找到重复的答案。
注意: 这是抽屉原理的应用——鸽子比抽屉多,因此一个抽屉必须包含两只鸽子。如果你感兴趣,请点击鸽子图标,阅读有关抽屉原理的更多信息
|
- 鸽子: 3 的幂
.
- 抽屉: 七个可能的余数
.
|
一旦某个数字重复,从那个数字首次出现的地方开始,后面的序列就必须与之前的序列相同。我们甚至可以看到,我们会在重复第一次发生的地方得到一个 1 然后是一个 3。为什么呢? 假设我们有一个重复的数字,换句话说 ,其中 a 和 b 是正数。那么 ,我们可以将两边都除以 ,得到 ,即更早出现的重复。只需要稍微注意一下。在模算术中,并不总是允许除以公因数。我们在这里允许进行除法,因为我们之前使用欧几里德算法确定了对素数进行模运算。我们知道 不为零,因为否则 3 将是 7 的一个因数,而 7 是素数。
|
关于模运算需要注意的是,我们不能随意地对所有数字进行取模运算。例如,在
的情况下,
中的
的指数不能直接替换为
,因为
。需要特别注意的是指数。在诸如
和
的表达式中,将 1000 替换为
和
,甚至
和
是可以的。
练习:3 的幂
- 现在轮到你了。执行与示例中相同的操作,但这次针对
。
|
这里 3 没有什么特殊之处。我们可以对其他数字进行相同的练习
,其中
。我们可能会更快地达到
,对于
,我们一定会这样,但我们仍然会得到
。
我们将通过多种方式证明这一点。之所以要费力地证明它,是因为它有助于我们看到证明结果的不同方法。在本例中,它主要是一种展示可以使用不同符号的方式。证明的第三种变体还将介绍乘性函数的概念,这在后面会很重要。