Problems on Boolean Logic Circuits and Algorithms 1. Convert the binary numbers (110001), (100000), (101011) to the decimal number. 2. Complete the following algebraic operations: (1000)+(1111)=?, (10110)+(110011)=?, (11001)-(1001)=?, (10110)-(1111101)=? 3. Design a half adder circuit to add two one digit binary numbers with zero carry. Answer Let us obtain a Truth Table for two digit addition: Input A 0 0 1 1 Input B 0 1 0 1 Carry digit C 0 0 0 1 Sum digit S 0 1 1 0 If the carry C is zero then one obtain sum of two numbers. 4. Design a full adder circuit two add two numbers. Again we obtain truth table: Carry IN 0 0 0 0 1 1 1 1 Input A 0 0 1 1 0 0 1 1 Input B 0 1 0 1 0 1 0 1 Carry digit C 0 0 0 1 0 1 1 1 Sum digit S 0 1 1 0 1 0 0 1 In order to design full adder circuits for more bit binary numbers we connect full adders. 5. An SR Flip Flop is an arrangements of logic gates that maintains a stable output even after the inputs are turned off. This is a simple model of how a bit of RAM can be perpetuated. There are many issues not shown here such as timing inputs and synchronization, but the simplicity of the circuit gives you an idea of how RAM operates. What is the truth table of the following SR Flip Flop circuit. 6.Write an algorithm to obtain greatest common divisor of two numbers v and u. Determine GCD of 81 and 45. Answer: If u=0 then GCD is v OR if v=0 then GCD is u. If u and v different from zero then we can obtain GCD of the numbers such that: if u>v then calculate u-v continue calculation till v>u then calculate v-u... after calculation completed if v=u then the result is u. u=81; v=45 81-45=36 45-36=9 36-9=27 27-9=18 18-9=9 9-9=0, then GCD=9. Problem 7. Factorize the following 617 deciman digit number in order to win a prize US$200,000. RSA-2048 = 25195908475657893494027183240048398571429282126204032027777137836043662020 70759555626401852588078440691829064124951508218929855914917618450280848912 00728449926873928072877767359714183472702618963750149718246911650776133798 59095700097330459748808428401797429100642458691817195118746121515172654632 28221686998754918242243363725908514186546204357679842338718477444792073993 42365848238242811981638150106748104516603773060562016196762561338441436038 33904414952634432190114657544454178424020924616515723350778707749817125772 46796292638635637328991215483143816789988504044536402352738195137863656439 1212010397122822120720357 Problem 8. Write a factorization algorithm. Answer. a) Trial division. (you can try to write a computer program) For example a mathematica code for factorization of number m is: 2 2 2 2 2 11 13 b)Fermat Factorization This algorithm was discovered by mathematician Pierre de Fermat in the 1600s. Fermat rewrite the number N as the difference of the squares. π = π₯ 2 − π¦2 Then the factorization: π = (π₯ + π¦)(π₯ − π¦) We can formulate: π = π‘π ; π‘ = (π₯ + π¦); π = (π₯ − π¦)ππ π₯ = π +π‘ π‘−π ;π¦ = . 2 2 We begin with π₯π = √π then check the above relations by increasing value of π₯π . A mathematica Sub program is given by: m=4576;x=Floor[Sqrt[m]]; While[x<m,x=x+1;If[Sqrt[x^2- -m]; Print[(x+y)," ", (x-y)],Continue[]]] c) A probabilistic Factorization: Pollard rho Factorization Pollard's rho method is a probabilistic method for factoring a composite number N by iterating a polynomial modulo N. Suppose we construct the sequence: π₯0 ≡ 2(πππ π) π₯π+1 = π₯π2 + 1 (πππ π) This sequence will eventually become periodic. Developed form of the algorithm and a simple mathematica program are given below. INPUT: Given number, n An integer a, 1<a<n-1 (GCD(a,n)=1) Determine period of the the number f(x)=a x (mod n) If x is even then the number can be written as (a a/2+1)(aa/2-1)=0 (mod n) Therefore; p= GCD[z+1,m]; q=GCD[z-1,m]; and n=pq m=1;n=45;a=43;s={};While[True, If[m>n,Break[],s=Append[s,PowerMod[a,m,n]]];m++];s {43,4,37,16,13,19,7,31,28,34,22,1,43,4,37,16,13,19,7,31,28,34,22,1,43,4,37,16,13,19,7,31,28,34,22,1,43,4,37,16,13,19,7,31} z=a^(Length[Union[s]]/2) p=GCD[z+1,m] q=GCD[z-1,m] n===p*q 6321363049 5 9 True