Docsity

CS160 Fall 2009 Homework 4: Mathematics and Cryptography, Assignments of Computer Science

Toggle sidebar
bg1
CS160, Fall 2009: Homework 4 (theory)
Due: October 1,2
1. Integer division
What are the quotient and remainder when:
(a) 44 is divided by 8?
(b) -129 is divided by 19?
(c) -1 is divided by 3
Note that we are using the mathematical definition, rather than the Java implementation.
2. Decide whether each of these integers is congruent to 5 modulo 17:
80, 103, -29, -122.
3. Cryptography
Encrypt the message “HELLO WORLD” by translating the letters into numbers, applying the encryp-
tion function given, and then translating the numbers back into letters.
(a) f(p) = (p+3) mod 26
(b) f(p) = (p+7) mod 26
4. Primes
Determine whether each of these integers is prime:
19, 27, 93, 101, 107
5. Find the prime factorization of each of these integers:
39, 81, 101, 143, 289.
6. Which positive integers less than 24 are relatively prime to 24?
7. GCDs and LCMs
What are the greatest common divisors of these pairs of integers:
(a) 22·33·56,25·33·52
(b) 2 ·3·5·7·11 ·13,39·11 ·1714
(c) 22·7,53·13
(d) 17,1717
(e) 2 ·3·5·7,2·3·5·7
8. What is the least common multiple of each pair in the previous question?
9. Find gcd(1000,625) and lcm(1000,625) and verify that gcd(1000,625) ·lcm(1000,625) = 1000 ·625
10. If the product of two integers is 27·38·52·711 and their greatest common divisor is 23·34·5, what is
their least common multiple?
11. Base Conversions Convert these integers from decimal notation to binary notation:
(a) 221
(b) 505
pf2

Partial preview of the text

Download CS160 Fall 2009 Homework 4: Mathematics and Cryptography and more Assignments Computer Science in PDF only on Docsity!

CS160, Fall 2009: Homework 4 (theory)

Due: October 1,

  1. Integer division What are the quotient and remainder when: (a) 44 is divided by 8? (b) -129 is divided by 19? (c) -1 is divided by 3 Note that we are using the mathematical definition, rather than the Java implementation.
  2. Decide whether each of these integers is congruent to 5 modulo 17: 80, 103, -29, -122.
  3. Cryptography Encrypt the message “HELLO WORLD” by translating the letters into numbers, applying the encryp- tion function given, and then translating the numbers back into letters. (a) f(p) = (p+3) mod 26 (b) f(p) = (p+7) mod 26
  4. Primes Determine whether each of these integers is prime: 19, 27, 93, 101, 107
  5. Find the prime factorization of each of these integers: 39, 81, 101, 143, 289.
  6. Which positive integers less than 24 are relatively prime to 24?
  7. GCDs and LCMs What are the greatest common divisors of these pairs of integers: (a) 2^2 · 33 · 56 , 25 · 33 · 52 (b) 2 · 3 · 5 · 7 · 11 · 13 , 39 · 11 · 1714 (c) 2^2 · 7 , 53 · 13 (d) 17, 1717 (e) 2 · 3 · 5 · 7 , 2 · 3 · 5 · 7
  8. What is the least common multiple of each pair in the previous question?
  9. Find gcd(1000,625) and lcm(1000,625) and verify that gcd(1000,625) · lcm(1000,625) = 1000 · 625
  10. If the product of two integers is 2^7 · 38 · 52 · 711 and their greatest common divisor is 2^3 · 34 · 5, what is their least common multiple?
  11. Base Conversions Convert these integers from decimal notation to binary notation: (a) 221 (b) 505
  1. Convert these integers from binary notation to decimal notation: (a) 1 1011 (b) 10 1011 0101
  2. Convert these integers from hexadecimal notation to binary notation: (a) 2C (b) (BEAD) 16
  3. Convert these integers from binary to hexadecimal notation: (a) 101 1010 0110 1011 (b) 10 1111 0101 0111 0011
  4. Conditionals What is printed after the following Java statements execute?

int x = 5; if ((1+5 == 5)||(2+3 < 5)) x = 4; System.out.println(x);

  1. Convert the following mathematical expression into a Java expression: x ≥ y ∧ x > 0
  2. Complete the following truth table based on variables p and q : Java Syntax Math Syntax p q p && !q p||!q !(p||q) p → ¬p p ⊕ (p ∨ q) (p ∧ q) → (p ∨ q) T T T F F T F F