Exercise Week 2
Exercise Week 2
(1) 1) a ≡ b modk ↔ ∃z ∈ Z : a − b = z ∗ k
2) (y mod k) = x ↔
x = ϵ{b | y ≡ b mod k ∧ b ∈ [0 : k − 1]}.
3) (y tmod k) = x ↔
x = ϵ{b | y ≡ b mod k ∧ b ∈ [−k/2 : k/2 − 1]}. (k has to be even)
(2) 1) 195 ≡ 6mod10 is false, because 195 − 6 = 189 and ̸ ∃z ∈ Z such that 189 = 10 ∗ z
2) 195 ≡ 5mod10 is true, because (195 − 5) = 190 = 19 ∗ 10 so take z = 19
3) 195 ≡ −6mod10 is false, because ̸ ∃z ∈ Z such that 201 = 10 ∗ z
4) (195mod10) = 5 is true, because first of all 195 ≡ 5mod10 is true, at the same time
5 ∈ [0 : 9]
5) (195mod10) = −5 is false, because even though congruence relation holds for -5,
−5 ̸∈ [0 : 9]
6) (195tmod10) = −5 is true, because first of all 195 ≡ −5mod10 and at the same time
−5 ∈ [−10/2 : 10/2 − 1] = [−5 : 4]
2) (minint − 1)tmodK = (−K/2 − 1)tmodK now we add until we are in range −K/2 −
1 + K = K/2 − 1 → (−K/2 − 1)tmodK = K/2 − 1 = maxint
3) −minint tmodK = K/2 tmodK = −K/2 = minint as we discussed in (1) exercise this
is how signed binary numbers work in every statically typed programming language (as I
know so far) let’s take an example in Java.
(5) modulo 2n is missing (think about an example where without modulo it won’t hold)
(8) ⟨1, 0⟩ = 1 ∗ 21 + 0 ∗ 20 = 1 ∗ 2 = 2 = 0 + 1 + 1 = 1 + 1 = 2