Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:
|
|
- Elvin Hunter
- 6 years ago
- Views:
Transcription
1 German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion: Exercise 3-1 ATM To be discussed in the tutorials Write a program that asks a user to enter his/her pincode to the ATM machine. The pincode is generated randomly once and user is notified with this pincode. The ATM machine then asks the user to enter the pincode and the user has maximum 3 trials to enter. After that, a corresponding message should be shown to the user. The output should be something like: Please enter your pincode 5643 Please enter your pincode 5645 Please enter your pincode 5465 You exceeded your trials. We will lock your account! p u b l i c c l a s s ATM Random r = new Random ( ) ; / / g e t random number between i n t p a s s = r. n e x t I n t ( )+1000; i n t n ; i n t i = 0 ; do System. o u t. p r i n t l n ( " P l e a s e e n t e r your p i n c o d e " ) ; n = sc. n e x t I n t ( ) ; System. o u t. p r i n t ( " " ) ; i ++; while ( p a s s!= n && i < 3 ) ; i f ( p a s s == n ) System. o u t. p r i n t l n ( " C o r r e c t p i n c o d e! " ) ; e l s e System. o u t. p r i n t l n ( "You exceeded your t r i a l s. We w i l l l o c k your a c c o u n t! " 1
2 Exercise 3-2 Adder To be discussed in the tutorials Write a program that adds up integers that the user enters. First the programs asks how many numbers will be added up. Then the program prompts the user for each number. Finally, it prints the sum. The output should be something like: How many integers will be added: 5 Enter integer 1: 3 Enter integer 2: 4 Enter integer 3: -4 Enter integer 4: -3 Enter integer 5: 7 The sum is 7 p u b l i c c l a s s Adding System. o u t. p r i n t l n ( "How many i n t e g e r s w i l l be added? " ) ; i n t n = sc. n e x t I n t ( ) ; i n t i, x, sum = 0 ; f o r ( i = 0 ; i <n ; i ++) System. o u t. p r i n t l n ( " E n t e r i n t e g e r " +( i + 1 ) ) ; x = sc. n e x t I n t ( ) sum += x ; System. o u t. p r i n t l n ( " The sum= "+sum ) ; Exercise 3-3 Euclidean Algorithm To be discussed in the tutorials The Euclidean algorithm determines the greatest common divisor (GCD) of two positive numbers by repeatedly replacing the larger number with the result of subtracting the smaller one from it until the two numbers are equal. Write a Java program for Euclidean algorithm where the user has to enter the two numbers and the program should calculate their greatest common divisor. The output should be something like: Please, enter a first number: 45 Please, enter a second number: 22 2
3 The GCD of 45 and 22 is 1 p u b l i c c l a s s E u c l i d i a n System. o u t. p r i n t l n ( " P l e a s e, e n t e r a number : " ) ; i n t num1 = sc. n e x t I n t ( ) ; System. o u t. p r i n t l n ( " P l e a s e, e n t e r a second number : " ) ; i n t num2 = sc. n e x t I n t ( ) ; i n t num1saved = num1 ; i n t num2saved = num2 ; while ( num1!= num2 ) i f ( num1 > num2 ) num1 = num2 ; e l s e num2 = num1 ; System. o u t. p r i n t l n ( " The GCD of " + num1saved + " and " + num2saved + " i s " + num1 ) ; Exercise 3-4 Caesar Cipher To be discussed in the tutorials Write a Java program which takes two input variables message of data type String and key of data type int. The program should shift each character in message with a distance of key. For example: if key=3 then a will be replaced by d and b will be replaced by e and so on. Hint: You can use the following method charat(int index): Returns the character at the specified index. The first character of the sequence is at index 0, the next at index 1 and so on. S t r i n g s = " H e l l o " ; char c = s. c h a r A t ( 0 ) ; The value of c is H. The output should be somthing like this: Please enter the Message: Hat Please Enter the Key: 3 The encrypted word is: Kdw 3
4 p u b l i c c l a s s C a e s a r System. o u t. p r i n t l n ( " P l e a s e E n t e r a Word t o be E n c r y p t e d : " ) ; S t r i n g s = sc. n e x t L i n e ( ) ; System. o u t. p r i n t l n ( " P l e a s e E n t e r a Key : " ) ; i n t key = sc. n e x t I n t ( ) ; char x ; i n t l = s. l e n g t h ( ) ; i n t a s c i i = 0 ; f o r ( i n t i = 0 ; i < l ; i ++) a s c i i = s. c h a r A t ( i ) + key ; i f ( ( a s c i i >122 && s. c h arat ( i ) >=97 && s. charat ( i ) <=122) ( a s c i i >90 && s. c harat ( i ) >=65 && s. c harat ( i ) <=90)) a s c i i = 2 6 ; x = ( char ) a s c i i ; System. o u t. p r i n t ( x ) ; System. o u t. p r i n t ( " \ n " ) ; Exercise 3-5 String Manipulation To be discussed in the labs Write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line. Read in the line into a String (in the usual way). Now use the charat() method in a loop to access the characters one by one. Use a switch statement to increment the appropriate variables based on the current character. After processing the line, print out the results. p u b l i c c l a s s Chars i n t c o n s o n a n t = 0, vowel = 0, p u n c t u a t i o n = 0, s p a c e = 0, d i g i t = 0 ; S t r i n g s t r, lowered ; System. o u t. p r i n t ( " E n t e r a s t r i n g : " ) ; s t r = sc. n e x t L i n e ( ) ; / / Convert t h e l e t t e r o f t h e S t r i n g s t r t o lower c ase. lowered = s t r. tolowercase ( ) ; f o r ( i n t i = 0 ; i < lowered. l e n g t h ( ) ; i ++) s w i t c h ( lowered. c h a r A t ( i ) ) c ase : s p a c e ++; break ; 4
5 c ase a : c ase e : c ase i : c ase o : c ase u : vowel ++; break ; c ase b : c ase c : c ase d : c ase f : c ase g : c ase h : c ase j : c ase k : c ase l : c ase m : c ase n : c ase p : c ase q : c ase r : c ase s : c ase t : c ase v : c ase w : c ase x : c ase y : c ase z : c o n s o n a n t ++; break ; c ase 0 : c ase 1 : c ase 2 : c ase 3 : c ase 4 : c ase 5 : c ase 6 : c ase 7 : c ase 8 : c ase 9 : d i g i t ++; break ; d e f a u l t : p u n c t u a t i o n ++; System. o u t. p r i n t l n ( " Number of c o n s o n a n t s : " + c o n s o n a n t ) ; System. o u t. p r i n t l n ( " Number of vowels : " + vowel ) ; System. o u t. p r i n t l n ( " Number of d i g i t s : " + d i g i t ) ; System. o u t. p r i n t l n ( " Number of p u n c t u a t i o n s : " + p u n c t u a t i o n ) ; System. o u t. p r i n t l n ( " Number of s p a c e s : " + s p a c e ) ; Exercise 3-6 Fixed Length Write a program that asks the user to enter two words. The program then prints out both words on one line. The words will be separated by enought dots so that the total line length is 30. We can use it to make an index for a book. The user enters the name of the chapters/sections and the page number and the program generate the index. You can only print one dot at a time. Enter first word: Chapter 5 5
6 Enter second word: 153 Chapter p u b l i c c l a s s Word S t r i n g word1, word2, l i n e = " " ; i n t d o t s ; System. o u t. p r i n t ( " E n t e r f i r s t word : " ) ; word1 = sc. n e x t L i n e ( ) ; System. o u t. p r i n t ( " E n t e r second word : " ) ; word2 = sc. n e x t L i n e ( ) ; d o t s = 30 ( word1. l e n g t h ( ) + word2. l e n g t h ( ) ) ; l i n e = l i n e. c o n c a t ( word1 ) ; f o r ( i n t i = 0 ; i < d o t s ; i ++) l i n e = l i n e. c o n c a t ( ". " ) ; l i n e = l i n e. c o n c a t ( word2 ) ; System. o u t. p r i n t l n ( l i n e ) ; Exercise 3-7 Stream of Numbers Write a Java program to read a list of nonnegative integers and outputs the maximum integer, the minimum integer, and the average of all the integers. The end of the input is indicated by the user entering a negative number. Note that the negative number is not used in finding the maximum, minimum, or average. The output should be something like this: Please enter a sequence of positive numbers The maximum number is : 5 The minimum number is: 2 The average is: 3.5 Use in one program a while loop and in another program a do while loop. Using While p u b l i c c l a s s NumbersWhile 6
7 System. o u t. p r i n t l n ( " P l e a s e e n t e r t h e number " ) ; i n t num = sc. n e x t I n t ( ) ; i f ( num<0) System. o u t. p r i n t l n ( "No p o s i t i v e Numbers e n t e r e d " ) ; e l s e i n t small, l a r g e ; s m a l l = num ; l a r g e = num ; double sum = 0 ; double avg ; i n t c o u n t = 0 ; while ( num>=0) i f ( num< s m a l l ) s m a l l = um ; e l s e i f ( num> l a r g e ) l a r g e = num ; sum += num ; c o u n t ++; System. o u t. p r i n t l n ( " P l e a s e e n t e r a n o t h e r number : " ) ; num = sc. n e x t I n t ( ) ; avg = sum / c o u n t ; System. o u t. p r i n t l n ( " The a v e r a g e of t h e numbers i s " + avg ) ; System. o u t. p r i n t l n ( " The s m a l l e s t i n t e g e r you e n t e r e d i s " + s m a l l ) ; System. o u t. p r i n t l n ( " The l a r g e s t i n t e g e r you e n t e r e d i s " + l a r g e ) ; Using Do While c l a s s NumbersDoWhile System. o u t. p r i n t l n ( " P l e a s e E n t e r a s e q u e n c e of p o s i t i v e numbers : " ) ; i n t i ; / / G e t t i n g t h e f i r s t number and a s s i g n i n g i t t o min and max i = sc. n e x t I n t ( ) ; i n t max = i, min = i, sum = 0, c o u n t = 0 ; i f ( i <0) System. o u t. p r i n t l n ( "No p o s i t i v e numbers e n t e r e d " ) ; e l s e do i f ( max< i ) max = i ; i f ( min> i ) min = i ; sum += i ; c o u n t ++; 7
8 i = sc. n e x t I n t ( ) ; while ( i > 0 ) ; double avg = ( double ) sum / c o u n t ; System. o u t. p r i n t l n ( " The maximum number i s " + max ) ; System. o u t. p r i n t l n ( " The minimum number i s " + min ) ; System. o u t. p r i n t l n ( " The a v e r a g e i s " + avg ) ; Exercise 3-8 Triangle N To be discussed in the labs Write a Java program to construct a triangle shape of numbers given that n is an input from the user. For example if n=6, the shape should look like the following: Solve using a single loop only. p u b l i c c l a s s T r i a n g l e System. o u t. p r i n t l n ( " P l e a s e e n t e r t h e number " ) ; i n t n = sc. n e x t I n t ( ) ; i n t i, j ; S t r i n g s = " " ; f o r ( i = 1 ; i <= n ; i ++) s += i ; System. o u t. p r i n t l n ( s ) ; 8
Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion:
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Rimon Elias Dr. Hisham Othman Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:
More informationMATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.
MATH 501 Discrete Mathematics Lecture 6: Number theory Prof. Dr. Slim Abdennadher, slim.abdennadher@guc.edu.eg German University Cairo, Department of Media Engineering and Technology 1 Number theory Number
More informationMAT 243 Test 2 SOLUTIONS, FORM A
MAT Test SOLUTIONS, FORM A 1. [10 points] Give a recursive definition for the set of all ordered pairs of integers (x, y) such that x < y. Solution: Let S be the set described above. Note that if (x, y)
More informationHomework #2 solutions Due: June 15, 2012
All of the following exercises are based on the material in the handout on integers found on the class website. 1. Find d = gcd(475, 385) and express it as a linear combination of 475 and 385. That is
More informationCS Exam 1 Study Guide and Practice Exam
CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................
More informationFall 2017 September 20, Written Homework 02
CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 September 20, 2017 Assigned: Wed 20 Sep 2017 Due: Fri 06 Oct 2017 Instructions: Written Homework 02 The assignment has to be uploaded to
More informationECE 646 Lecture 5. Mathematical Background: Modular Arithmetic
ECE 646 Lecture 5 Mathematical Background: Modular Arithmetic Motivation: Public-key ciphers RSA as a trap-door one-way function PUBLIC KEY message ciphertext M C = f(m) = M e mod N C M = f -1 (C) = C
More informationThe Euclidean Algorithm and Multiplicative Inverses
1 The Euclidean Algorithm and Multiplicative Inverses Lecture notes for Access 2009 The Euclidean Algorithm is a set of instructions for finding the greatest common divisor of any two positive integers.
More informationcse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications
cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i
More informationIntermediate Math Circles February 29, 2012 Linear Diophantine Equations I
Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I Diophantine equations are equations intended to be solved in the integers. We re going to focus on Linear Diophantine Equations.
More informationcse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications
cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible
More information17.1 Binary Codes Normal numbers we use are in base 10, which are called decimal numbers. Each digit can be 10 possible numbers: 0, 1, 2, 9.
( c ) E p s t e i n, C a r t e r, B o l l i n g e r, A u r i s p a C h a p t e r 17: I n f o r m a t i o n S c i e n c e P a g e 1 CHAPTER 17: Information Science 17.1 Binary Codes Normal numbers we use
More informationCSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD
CSE 311: Foundations of Computing Lecture 12: Two s Complement, Primes, GCD n-bit Unsigned Integer Representation Represent integer as sum of powers of 2: If 2 where each {0,1} then representation is b
More informationCS 163/164 - Exam 1 Study Guide and Practice Exam
CS 163/164 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Strings...................................................
More informationPublic Key Cryptography
Public Key Cryptography Spotlight on Science J. Robert Buchanan Department of Mathematics 2011 What is Cryptography? cryptography: study of methods for sending messages in a form that only be understood
More informationCSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam
Page 0 German University in Cairo June 14, 2014 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam Bar Code
More informationOn my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work
Lab 5 : Linking Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The main objective of this lab is to experiment
More informationDefinition For a set F, a polynomial over F with variable x is of the form
*6. Polynomials Definition For a set F, a polynomial over F with variable x is of the form a n x n + a n 1 x n 1 + a n 2 x n 2 +... + a 1 x + a 0, where a n, a n 1,..., a 1, a 0 F. The a i, 0 i n are the
More informationECE 646 Lecture 5. Motivation: Mathematical Background: Modular Arithmetic. Public-key ciphers. RSA keys. RSA as a trap-door one-way function
ECE Lecture 5 Mathematical Background: Modular Arithmetic Motivation: Public-key ciphers RSA as a trap-door one-way function PUBLIC KEY message ciphertext M C = f(m) = M e mod N C RSA keys PUBLIC KEY PRIVATE
More informationCryptology with DERIVE in the classroom
Liverpool John Moores University, July 12 15, 2000 Cryptology with DERIVE in the classroom Dirk Warthmann St. Ursula-Gymnasium, Düsseldorf, Germany e-mail: d.warthmann@gmx.de The encryption and decryption
More informationthen the hard copy will not be correct whenever your instructor modifies the assignments.
Assignments for Math 2030 then the hard copy will not be correct whenever your instructor modifies the assignments. exams, but working through the problems is a good way to prepare for the exams. It is
More informationCryptography. P. Danziger. Transmit...Bob...
10.4 Cryptography P. Danziger 1 Cipher Schemes A cryptographic scheme is an example of a code. The special requirement is that the encoded message be difficult to retrieve without some special piece of
More informationClock Arithmetic and Euclid s Algorithm
Clock Arithmetic and Euclid s Algorithm Lecture notes for Access 2008 by Erin Chamberlain. Earlier we discussed Caesar Shifts and other substitution ciphers, and we saw how easy it was to break these ciphers
More informationEncryption: The RSA Public Key Cipher
Encryption: The RSA Public Key Cipher Michael Brockway March 5, 2018 Overview Transport-layer security employs an asymmetric public cryptosystem to allow two parties (usually a client application and a
More informationDiscrete Structures Lecture Primes and Greatest Common Divisor
DEFINITION 1 EXAMPLE 1.1 EXAMPLE 1.2 An 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.
More informationChapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)
CSE 54 Discrete Mathematics & Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices Integers & Algorithms (Section 2.5) by Kenneth H. Rosen, Discrete Mathematics & its Applications,
More informationFactoring. Number Theory # 2
1 Number Theory # 2 Factoring In the last homework problem, it takes many steps of the Euclidean algorithm to find that the gcd of the two numbers is 1. However, if we had initially observed that 11384623=5393*2111,
More informationCSEN102 Introduction to Computer Science
CSEN102 Introduction to Computer Science Lecture 7: Representing Information I Prof. Dr. Slim Abdennadher Dr. Mohammed Salem, slim.abdennadher@guc.edu.eg, mohammed.salem@guc.edu.eg German University Cairo,
More information1. Write a program to calculate distance traveled by light
G. H. R a i s o n i C o l l e g e O f E n g i n e e r i n g D i g d o h H i l l s, H i n g n a R o a d, N a g p u r D e p a r t m e n t O f C o m p u t e r S c i e n c e & E n g g P r a c t i c a l M a
More informationIntroduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee
Introduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee Lecture 05 Problem discussion on Affine cipher and perfect secrecy
More informationExercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.
Exercises Exercises 1. Determine whether each of these integers is prime. a) 21 b) 29 c) 71 d) 97 e) 111 f) 143 2. Determine whether each of these integers is prime. a) 19 b) 27 c) 93 d) 101 e) 107 f)
More informationElementary Number Theory MARUCO. Summer, 2018
Elementary Number Theory MARUCO Summer, 2018 Problem Set #0 axiom, theorem, proof, Z, N. Axioms Make a list of axioms for the integers. Does your list adequately describe them? Can you make this list as
More informationKnow the meaning of the basic concepts: ring, field, characteristic of a ring, the ring of polynomials R[x].
The second exam will be on Friday, October 28, 2. It will cover Sections.7,.8, 3., 3.2, 3.4 (except 3.4.), 4. and 4.2 plus the handout on calculation of high powers of an integer modulo n via successive
More informationData Structures and Algorithms Winter Semester
Page 0 German University in Cairo December 26, 2015 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher Dr. Wael Abouelsadaat Data Structures and Algorithms Winter Semester 2015-2016 Final
More informationMathematics of Cryptography
Modulo arithmetic Fermat's Little Theorem If p is prime and 0 < a < p, then a p 1 = 1 mod p Ex: 3 (5 1) = 81 = 1 mod 5 36 (29 1) = 37711171281396032013366321198900157303750656 = 1 mod 29 (see http://gauss.ececs.uc.edu/courses/c472/java/fermat/fermat.html)
More informationSol: First, calculate the number of integers which are relative prime with = (1 1 7 ) (1 1 3 ) = = 2268
ò{çd@àt ø 2005.0.3. Suppose the plaintext alphabets include a z, A Z, 0 9, and the space character, therefore, we work on 63 instead of 26 for an affine cipher. How many keys are possible? What if we add
More informationUniversity of Regina Department of Mathematics & Statistics Final Examination (April 21, 2009)
Make sure that this examination has 10 numbered pages University of Regina Department of Mathematics & Statistics Final Examination 200910 (April 21, 2009) Mathematics 124 The Art and Science of Secret
More informationL435/L555. Dept. of Linguistics, Indiana University Fall 2016
in in L435/L555 Dept. of Linguistics, Indiana University Fall 2016 1 / 13 in we know how to output something on the screen: print( Hello world. ) input: input() returns the input from the keyboard
More information19. Coding for Secrecy
19. Coding for Secrecy 19.1 Introduction Protecting sensitive information from the prying eyes and ears of others is an important issue today as much as it has been for thousands of years. Government secrets,
More informationComputer Science Introductory Course MSc - Introduction to Java
Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow
More informationDiscrete Mathematics GCD, LCM, RSA Algorithm
Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common
More informationFormal Methods in Software Engineering
Formal Methods in Software Engineering Modeling Prof. Dr. Joel Greenyer October 21, 2014 Organizational Issues Tutorial dates: I will offer two tutorial dates Tuesdays 15:00-16:00 in A310 (before the lecture,
More informationIntroduction to Number Theory. The study of the integers
Introduction to Number Theory The study of the integers of Integers, The set of integers = {... 3, 2, 1, 0, 1, 2, 3,...}. In this lecture, if nothing is said about a variable, it is an integer. Def. We
More informationNET 311D INFORMATION SECURITY
1 NET 311D INFORMATION SECURITY Networks and Communication Department TUTORIAL 3 : Asymmetric Ciphers (RSA) A Symmetric-Key Cryptography (Public-Key Cryptography) Asymmetric-key (public key cryptography)
More informationIntermediate Math Circles February 26, 2014 Diophantine Equations I
Intermediate Math Circles February 26, 2014 Diophantine Equations I 1. An introduction to Diophantine equations A Diophantine equation is a polynomial equation that is intended to be solved over the integers.
More informationSecurity II: Cryptography exercises
Security II: Cryptography exercises Markus Kuhn Lent 2015 Part II Some of the exercises require the implementation of short programs. The model answers use Perl (see Part IB Unix Tools course), but you
More informationA Readable Introduction to Real Mathematics
Solutions to selected problems in the book A Readable Introduction to Real Mathematics D. Rosenthal, D. Rosenthal, P. Rosenthal Chapter 7: The Euclidean Algorithm and Applications 1. Find the greatest
More informationNumber theory (Chapter 4)
EECS 203 Spring 2016 Lecture 12 Page 1 of 8 Number theory (Chapter 4) Review Compute 6 11 mod 13 in an efficient way What is the prime factorization of 100? 138? What is gcd(100, 138)? What is lcm(100,138)?
More informationNumber Theory Notes Spring 2011
PRELIMINARIES The counting numbers or natural numbers are 1, 2, 3, 4, 5, 6.... The whole numbers are the counting numbers with zero 0, 1, 2, 3, 4, 5, 6.... The integers are the counting numbers and zero
More informationSolution to Midterm Examination
YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPSC 467a: Cryptography and Computer Security Handout #13 Xueyuan Su November 4, 2008 Instructions: Solution to Midterm Examination This is a closed book
More informationNotes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I
Number Theory: Applications Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Fall 2007 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 3.4 3.7 of Rosen cse235@cse.unl.edu
More informationCh 4.2 Divisibility Properties
Ch 4.2 Divisibility Properties - Prime numbers and composite numbers - Procedure for determining whether or not a positive integer is a prime - GCF: procedure for finding gcf (Euclidean Algorithm) - Definition:
More informationE23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101
E23: Hotel Management System Author: 1302509 Zhao Ruimin 1301478 Wen Yunlu 1302575 Hu Xing 1301911 Chen Ke 1302599 Tang Haoyuan Module: EEE 101 Lecturer: Date: Dr.Lin December/22/2014 Contents Contents
More informationCryptography CS 555. Topic 2: Evolution of Classical Cryptography CS555. Topic 2 1
Cryptography CS 555 Topic 2: Evolution of Classical Cryptography Topic 2 1 Lecture Outline Basics of probability Vigenere cipher. Attacks on Vigenere: Kasisky Test and Index of Coincidence Cipher machines:
More informationIntroduction to Programming (Java) 3/12
Introduction to Programming (Java) 3/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction
More informationNUMBER THEORY AND CODES. Álvaro Pelayo WUSTL
NUMBER THEORY AND CODES Álvaro Pelayo WUSTL Talk Goal To develop codes of the sort can tell the world how to put messages in code (public key cryptography) only you can decode them Structure of Talk Part
More informationMa/CS 6a Class 1. Course Details
Ma/CS 6a Class 1 By Adam Sheffer Course Details Adam Sheffer. adamsh@caltech.edu 1:00 Monday, Wednesday, and Friday. http://www.math.caltech.edu/~2014-15/1term/ma006a/ 1 Course Structure No exam! Grade
More information26 HIDDEN MARKOV MODELS
26 HIDDEN MARKOV MODELS techniques to HMMs. Consequently, a clear understanding of the material in this chapter is crucial before proceeding with the remainder of the book. The homework problem will help
More informationDesigning Information Devices and Systems I Fall 2018 Lecture Notes Note 21
EECS 16A Designing Information Devices and Systems I Fall 2018 Lecture Notes Note 21 21.1 Module Goals In this module, we introduce a family of ideas that are connected to optimization and machine learning,
More informationECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University
ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation
More informationJong C. Park Computer Science Division, KAIST
Jong C. Park Computer Science Division, KAIST Today s Topics The Euclidean Algorithm The RSA Public-Key Cryptosystem Discrete Mathematics, 2008 2 Computer Science Division, KAIST Note If r = a mod b, then
More informationAn Introduction to Cryptography
An Introduction to Cryptography Spotlight on Science J. Robert Buchanan Department of Mathematics Spring 2008 What is Cryptography? cryptography: study of methods for sending messages in a form that only
More informationSecurity of Networks (12) Exercises
(12) Exercises 1.1 Below are given four examples of ciphertext, one obtained from a Substitution Cipher, one from a Vigenere Cipher, one from an Affine Cipher, and one unspecified. In each case, the task
More informationNumber Theory Proof Portfolio
Number Theory Proof Portfolio Jordan Rock May 12, 2015 This portfolio is a collection of Number Theory proofs and problems done by Jordan Rock in the Spring of 2014. The problems are organized first by
More informationThe Hill Cipher A Linear Algebra Perspective
The Hill Cipher A Linear Algebra Perspective Contents 1 Introduction to Classical Cryptography 3 1.1 Alice, Bob & Eve................................. 3 1.2 Types of Attacks.................................
More informationMONOALPHABETIC CIPHERS AND THEIR MATHEMATICS. CIS 400/628 Spring 2005 Introduction to Cryptography
MONOALPHABETIC CIPHERS AND THEIR MATHEMATICS CIS 400/628 Spring 2005 Introduction to Cryptography This is based on Chapter 1 of Lewand and Chapter 1 of Garrett. MONOALPHABETIC SUBSTITUTION CIPHERS These
More informationNumber Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers
Number Theory: Applications Number Theory Applications Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Results from Number Theory have many applications
More informationOutline. policies for the first part. with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014
Outline 1 midterm exam on Friday 11 July 2014 policies for the first part 2 questions with some potential answers... MCS 260 Lecture 10.0 Introduction to Computer Science Jan Verschelde, 9 July 2014 Intro
More informationCPSC 467b: Cryptography and Computer Security
CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively
More informationTuring Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1
Turing Machines a n b n c The anguage Hierarchy n? ww? Context-Free anguages a n b n egular anguages a * a *b* ww Courtesy Costas Busch - PI a n b n c n Turing Machines anguages accepted by Turing Machines
More information11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic
11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic Bezout s Lemma Let's look at the values of 4x + 6y when x and y are integers. If x is -6 and y is 4 we
More informationCPSC 467b: Cryptography and Computer Security
CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 3 January 22, 2013 CPSC 467b, Lecture 3 1/35 Perfect secrecy Caesar cipher Loss of perfection Classical ciphers One-time pad Affine
More informationAdmin. ! Will post sample questions soon. 1. Choose a bit-length k. 2. Choose two primes p and q which can be represented with at most k bits
Admin Assignment 6 Midterm reviews Tue & Wed! Will post sample questions soon ENCRYPTION TAKE 2: PRACTICAL DETAILS Assignment 7 Office hours end today at 3:40 (instead of 4) David Kauchak CS52 Spring 2016
More informationImplementation Tutorial on RSA
Implementation Tutorial on Maciek Adamczyk; m adamczyk@umail.ucsb.edu Marianne Magnussen; mariannemagnussen@umail.ucsb.edu Adamczyk and Magnussen Spring 2018 1 / 13 Overview Implementation Tutorial Introduction
More informationTECHNISCHE UNIVERSITEIT EINDHOVEN Faculty of Mathematics and Computer Science Exam Cryptology, Tuesday 30 October 2018
Faculty of Mathematics and Computer Science Exam Cryptology, Tuesday 30 October 2018 Name : TU/e student number : Exercise 1 2 3 4 5 total points Notes: Please hand in all sheets at the end of the exam.
More informationFunctions and Their Graphs
Functions and Their Graphs DEFINITION Function A function from a set D to a set Y is a rule that assigns a unique (single) element ƒ(x) Y to each element x D. A symbolic way to say y is a function of x
More informationSection Summary. Division Division Algorithm Modular Arithmetic
1 Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their properties. Key ideas in number theory include divisibility and the primality of integers. Representations
More informationCS Asymptotic Notations for Algorithm Analysis
CS483-02 Asymptotic Notations for Algorithm Analysis Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/
More informationThe Euclidean Algorithm
MATH 324 Summer 2006 Elementary Number Theory Notes on the Euclidean Algorithm Department of Mathematical and Statistical Sciences University of Alberta The Euclidean Algorithm Given two positive integers
More informationCRYPTOGRAPHY AND NUMBER THEORY
CRYPTOGRAPHY AND NUMBER THEORY XINYU SHI Abstract. In this paper, we will discuss a few examples of cryptographic systems, categorized into two different types: symmetric and asymmetric cryptography. We
More informationThe set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }
Integers and Division 1 The Integers and Division This area of discrete mathematics belongs to the area of Number Theory. Some applications of the concepts in this section include generating pseudorandom
More informationNumber Theory and Cryptography
. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Number Theory and
More informationMath 430 Exam 1, Fall 2006
c IIT Dept. Applied Mathematics, October 21, 2008 1 PRINT Last name: Signature: First name: Student ID: Math 430 Exam 1, Fall 2006 These theorems may be cited at any time during the test by stating By
More informationWeek 7 An Application to Cryptography
SECTION 9. EULER S GENERALIZATION OF FERMAT S THEOREM 55 Week 7 An Application to Cryptography Cryptography the study of the design and analysis of mathematical techniques that ensure secure communications
More informationDo not start until you are given the green signal
SOLUTIONS CSE 311 Winter 2011: Midterm Exam (closed book, closed notes except for 1-page summary) Total: 100 points, 5 questions. Time: 50 minutes Instructions: 1. Write your name and student ID on the
More informationCPSC 121 Sample Final Examination December 2013
CPSC 121 Sample Final Examination December 201 [6] 1. Short answers [] a. What is wrong with the following circuit? You can not connect the outputs of two or more gates together directly; what will happen
More informationC++ For Science and Engineering Lecture 13
C++ For Science and Engineering Lecture 13 John Chrispell Tulane University Wednesday September 22, 2010 Logical Expressions: Sometimes you want to use logical and and logical or (even logical not) in
More informationPart I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS
CS131 Part I, Number Systems CS131 Mathematics for Computer Scientists II Note 1 INTEGERS The set of all integers will be denoted by Z. So Z = {..., 2, 1, 0, 1, 2,...}. The decimal number system uses the
More informationMath Circles Cryptography
Math Circles Cryptography Nickolas Rollick nrollick@uwaterloo.ca March 7, 2018 Introduction Last time, we talked about public key cryptography, an idea from the 1970s that opened the door for encryption
More informationWritten examination. Tuesday, August 18, 2015, 08:30 a.m.
Advanced Methods of Cryptography Univ.-Prof. Dr. rer. nat. Rudolf Mathar 1 2 3 4 19 20 11 20 70 Written examination Tuesday, August 18, 2015, 08:30 a.m. Name: Matr.-No.: Field of study: Please pay attention
More informationSenior Math Circles Cryptography and Number Theory Week 2
Senior Math Circles Cryptography and Number Theory Week 2 Dale Brydon Feb. 9, 2014 1 Divisibility and Inverses At the end of last time, we saw that not all numbers have inverses mod n, but some do. We
More informationDM49-2. Obligatoriske Opgave
DM49-2. Obligatoriske Opgave Jacob Christiansen, moffe42, 130282 Thomas Nordahl Pedersen, nordahl, 270282 1/4-05 Indhold 1 Opgave 1 - Public Exponent 2 1.1 a.................................. 2 1.2 b..................................
More informationFirst Midterm Examination
2015-2016 Spring Semester First Midterm Examination 1) How many numbers in the set {1000, 1001, 1002,..., 9999} have sum of digits equal to 17? 2) Let n Z +. Find the negation, converse and contrapositive
More informationACCESS: Cryptography
ACCESS: Cryptography E. Chamberlain, F. Guevara Vasquez, C. Hohenegger, and N. Korevaar June 24, 2014 1 Introduction Cryptography or the art of transmitted hidden messages has been long associated for
More informationCOMP424 Computer Security
COMP424 Computer Security Prof. Wiegley jeffw@csun.edu Rivest, Shamir & Adelman (RSA) Implementation 1 Relatively prime Prime: n, is prime if its only two factors are 1 and n. (and n 1). Relatively prime:
More informationNumber Theory A focused introduction
Number Theory A focused introduction This is an explanation of RSA public key cryptography. We will start from first principles, but only the results that are needed to understand RSA are given. We begin
More informationModular Arithmetic. Examples: 17 mod 5 = 2. 5 mod 17 = 5. 8 mod 3 = 1. Some interesting properties of modular arithmetic:
Modular Arithmetic If a mod n = b, then a = c n + b. When you reduce a number a modulo n you usually want 0 b < n. Division Principle [Bar02, pg. 61]: Let n be a positive integer and let a be any integer.
More informationCompiling Techniques
Lecture 3: Introduction to 22 September 2017 Reminder Action Create an account and subscribe to the course on piazza. Coursework Starts this afternoon (14.10-16.00) Coursework description is updated regularly;
More information