Upcoming SlideShare
×

# Number theory

618 views
523 views

Published on

Published in: Education, Technology
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
618
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
39
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Number theory

1. 1. Number Theory And Systems
2. 2. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of • greatest common divisors, • least common multiples, and • modular arithmetic and look at some relevant algorithms.
3. 3. Primes A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p. A positive integer that is greater than 1 and is not prime is called composite. The fundamental theorem of arithmetic: Every positive integer can be written uniquely as the product of primes, where the prime factors are written in order of increasing size.
4. 4. Primes Examples: 3·5 48 = 17 = 100 = 512 = 515 = 28 = 15 = 2·2·2·2·3 = 24·3 17 2·2·5·5 = 22·52 2·2·2·2·2·2·2·2·2 = 29 5·103 2·2·7
5. 5. Least Common Multiples Definition: The least common multiple of the positive integers a and b is the smallest positive integer that is divisible by both a and b. We denote the least common multiple of a and b by lcm(a, b). Examples: lcm(3, 7) = 21 lcm(4, 6) = 12 lcm(5, 10) = 10
6. 6. Least Common Multiples Using prime factorizations: a = p1 a1 p2 a2 … pn an , b = p1 b1 p2 b2 … pn bn , where p1 < p2 < … < pn and ai, bi N for 1 i n lcm(a, b) = p1 max(a1 , b1 ) p2 max(a2 , b2 ) … pn max(an , bn ) Example: a = 60 = 22 31 51 b = 54 = 21 33 50 lcm(a, b) = 22 33 51 = 4 27 5 = 540
7. 7. Greatest Common Divisors Let a and b be integers, not both zero. The largest integer d such that d | a and d | b is called the greatest common divisor of a and b. The greatest common divisor of a and b is denoted by gcd(a, b). Example 1: What is gcd(48, 72) ? The positive common divisors of 48 and 72 are 1, 2, 3, 4, 6, 8, 12, 16, and 24, so gcd(48, 72) = 24. Example 2: What is gcd(19, 72) ? The only positive common divisor of 19 and 72 is 1, so gcd(19, 72) = 1.
8. 8. Greatest Common Divisors Using prime factorizations: a = p1 a1 p2 a2 … pn an , b = p1 b1 p2 b2 … pn bn , where p1 < p2 < … < pn and ai, bi N for 1 i n gcd(a, b) = p1 min(a1 , b1 ) p2 min(a2 , b2 ) … pn min(an , bn ) Example: a = 60 = 22 31 51 b = 54 = 21 33 50 gcd(a, b) = 21 31 50 = 6
9. 9. GCD and LCM a = 60 = 22 31 51 b = 54 = 21 33 50 lcm(a, b) = 22 33 51 = 540 gcd(a, b) = 21 31 50 = 6 Theorem: a b = gcd(a,b) lcm(a,b)
10. 10. Relatively Prime Integers Definition: Two integers a and b are relatively prime if gcd(a, b) = 1. Examples: Are 15 and 28 relatively prime? Yes, gcd(15, 28) = 1. Are 55 and 28 relatively prime? Yes, gcd(55, 28) = 1. Are 35 and 28 relatively prime? No, gcd(35, 28) = 7.
11. 11. Modular Arithmetic Let a be an integer and m be a positive integer. We denote by a mod m the remainder when a is divided by m. Examples: 9 mod 4 = 1 9 mod 3 = 0 9 mod 10 = 9 -13 mod 4 = 3
12. 12. Common Number Systems System Base Symbols Used by humans? Used in computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 No Yes Octal 8 0, 1, … 7 No No Hexa- decimal 16 0, 1, … 9, A, B, … F No No
13. 13. Quantities/Counting (1 of 3) Decimal Binary Octal Hexa- decimal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7
14. 14. Quantities/Counting (2 of 3) Decimal Binary Octal Hexa- decimal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F
15. 15. Quantities/Counting (3 of 3) Decimal Binary Octal Hexa- decimal 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 20 10100 24 14 21 10101 25 15 22 10110 26 16 Etc.
16. 16. Conversion Among Bases • The possibilities: Hexadecimal Decimal Octal Binary
17. 17. Quick Example 2510 = 110012 = 318 = 1916 Base
18. 18. Decimal to Decimal (just for fun) Hexadecimal Decimal Octal Binary Next slide…
19. 19. 12510 => 5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base Weight
20. 20. Binary to Decimal Hexadecimal Decimal Octal Binary
21. 21. Binary to Decimal • Technique – Multiply each bit by 2n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results
22. 22. Example 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310 Bit “0”
23. 23. Octal to Decimal Hexadecimal Decimal Octal Binary
24. 24. Octal to Decimal • Technique – Multiply each bit by 8n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results
25. 25. Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810
27. 27. Hexadecimal to Decimal • Technique – Multiply each bit by 16n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results
28. 28. Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810
29. 29. Decimal to Binary Hexadecimal Decimal Octal Binary
30. 30. Decimal to Binary • Technique – Divide by two, keep track of the remainder – First remainder is bit 0 (LSB, least-significant bit) – Second remainder is bit 1 – Etc.
31. 31. Example 12510 = ?2 2 125 62 12 31 02 15 12 7 12 3 12 1 12 0 1 12510 = 11111012
32. 32. Octal to Binary Hexadecimal Decimal Octal Binary
33. 33. Octal to Binary • Technique – Convert each octal digit to a 3-bit equivalent binary representation
34. 34. Example 7058 = ?2 7 0 5 111 000 101 7058 = 1110001012
36. 36. Hexadecimal to Binary • Technique – Convert each hexadecimal digit to a 4-bit equivalent binary representation
37. 37. Example 10AF16 = ?2 1 0 A F 0001 0000 1010 1111 10AF16 = 00010000101011112
38. 38. Decimal to Octal Hexadecimal Decimal Octal Binary
39. 39. Decimal to Octal • Technique – Divide by 8 – Keep track of the remainder
40. 40. Example 123410 = ?8 8 1234 154 28 19 28 2 38 0 2 123410 = 23228
42. 42. Decimal to Hexadecimal • Technique – Divide by 16 – Keep track of the remainder
43. 43. Example 123410 = ?16 123410 = 4D216 16 1234 77 216 4 13 = D16 0 4
44. 44. Binary to Octal Hexadecimal Decimal Octal Binary
45. 45. Binary to Octal • Technique – Group bits in threes, starting on right – Convert to octal digits
46. 46. Example 10110101112 = ?8 1 011 010 111 1 3 2 7 10110101112 = 13278