Mathematical Foundations

Modulo operation

there are two unique integers q and r such that a = qb + r,
where q = a/b , and 0 ≤ r < b. q and r are the quotient and remainder.
We write   r = a mod b.
--- Example: 89 mod 7 = 5 and -13 mod 6 = 5

Set of residues: Zn(余集)

----- The result of the modulo operation with modulus n is always an integer between 0 and n-1
-----The formed set is called the set of residues modulo n,or Zn
----- For each n, we have one set of residues, Zn={0,1,2,…,(n-1)}
---- for example: Z2={0,1}, Z6={0,1,2,3,4,5},

Properties of modular arithmetic


Example: Please proof the following reducibility of modular arithmetic,i.e.


Proof:  a=r1*n+q1,     b=r2*n+q2,

左边式子:(a+b) mod n=[( r1*n+q1)+( r2*n+q2)] mod n

=(0+0+q1+q2)mod n

=( q1+q2)modn

右边式子[(amod n)+(b mod n)] mod n

=[((r1*n+q1) mod n)+((r2*n+q2)mod n)] mod n

=(q1+q2)modn

∴左边等于右边,也即(a+b)mod n=[(a mod n)+(b mod n)]mod n



Proof:  a=r1*n+q1,     b=r2*n+q2,

左边式子:(a*b) mod n=[( r1*n+q1)*( r2*n+q2)] mod n

=(r1*r2*n2+r1*q2*n+r2*q1*n+q1*q2)modn

=(0+0+0+q1*q2)mod n

=( q1*q2)modn

右边式子[(amod n)*(b mod n)] mod n

=[((r1*n+q1) mod n)*((r2*n+q2)mod n)] mod n

=(q1*q2)modn

∴左边等于右边,也即(a*b)mod n=[(a mod n)*(b mod n)]mod n


Modular exponentiation


Example:Please computer 27357mod 17

Ans: 6

27357 mod 17

=[(27mod17) 357] mod 17=(10357)mod 17=(10256+64+32+4+1)mod 17

=[(10256mod17)*(1064mod17)*(1032mod17)*(104mod17)*(101mod17)]mod17

=[(10256mod17)*(1064mod17)*(1032mod17)*(104mod17)*(10)]mod17

=[(10256mod17)*(1064mod17)*(1032mod17)*(102mod17)*(102mod17)*(10)]mod 17

=[(10256mod17)*(1064mod17)*(1032mod17)*(15)*(15)*(10)]mod 17

=[(10256mod17)*(1064mod17)*(1032mod17)*((15*15)mod 17)*(10)]mod 17

=[(10256mod17)*(1064mod17)*(1032mod17)*(4)*(10)]mod17

=[(10256mod17)*(1064mod17)*((104mod17)8mod 17)*(4)*(10)]mod 17

=[(10256mod17)*(1064mod17)*(48mod 17)*(4)*(10)]mod 17

=[(10256mod17)*(1064mod17)*(1)*(4)*(10)]mod17

=[(10256mod17)*(1032mod17)*(1032mod17)*(1)*(4)*(10)]mod 17

=[(10256mod17)*(1*1 mod 17)*(1)*(4)*(10)]mod17

=[(10256mod17)*(1)*(1)*(4)*(10)]mod17

=[((1064mod17)4 mod17)* (1)*(1)*(4)*(10)]mod 17

=[((1)4 mod 17)* (1)*(1)*(4)*(10)]mod17

=[(1)* (1)*(1)*(4)*(10)]mod 17=[(1)* (1)*(1)*(4*10)mod17]mod 17

=[(40)mod 17]mod 17=6 mod 17

= 6

Additive Inverse

a+b=0(mod n)

在模运算中,每一个整数都有一个加法逆,它们之和模n为0

Multiplicative Inverse

Let x ∈ Zn. If there is an integer y ∈ Zn such that x n y = 1.
The integer y is called the multiplicative inverse of x, usually denoted x−1.

在集合Zn中,若g(n,a)=1时,a有一个乘法逆。

Random and pseudorandom numbers

Pseudorandom numbers: sequences of numbers that appear to be random generated by some algorithm
*** PRG: deterministic, not statistically random But can pass many randomness test
Example:
glibc random():
r[i] ← ( r[i-3] + r[i-31] ) % 232
output r[i] >> 1


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值