10 views

Uploaded by Abhimanyu Singh Hada

- LCM and HCF Tricks, Problems and Formulas _ Bank Exams Today
- 134_Sample_Chapter.pdf
- Superblocks
- a453guidancedocuments
- gcd
- IB-09limits(41-47)
- Contoh Soal
- 2012 Tut 4 on APGP (Soln for Sect C and D)
- eucli
- Algorithms and Flowchart
- Harnessing Sensor Networks
- Basic Algebra
- scimakelatex.20425.xxx6
- Book References and Topper Speak
- Best Book for Each Subject
- Decoupling IPv4 from Public-Private Key Pairs in Neural Networks
- ENGG407_Ch1_1 Numerical methods lecture one
- Number Theory UNSOLVED
- scimakelatex.16087.Terry+Gu
- 7-5.solution.pdf

You are on page 1of 6

3 AIM:

Develop a program in C++/Java, based on number theory such as Chinese Remainder or Extended Euclidean Algorithm.

THEORY:

Euclids Algorithm: The Greatest Common Divisor (GCD) of two integers is defined as follows: An integer c is called the GCD (a, b) (read as the greatest common divisor of integers a and b if the following 2 conditions hold : 1) C | a^c| b 2) For any common divisor d of a and b, d | c. Rule 2 ensures that the divisor c is the greatest of all the common divisors of a and b. Euclid devised a fairly simple and efficient algorithm to determine the GCF of two integers. The algorithm basically makes use of the division algorithm repeatedly. Lets find the GCD (a,b), where a and b are integers with a>=b>0 Euclids algorithm says to write out the following: a=q1b+r1, b=q2r1+r2, r1=q3r2+r3, . ri=qi+2ri+1+ri+2, rk-1=qk+1rk Euclids algorithm says that the GCD (a,b)=rk Consider computing GCD (125, 87) where 0<ri+2<ri+1 where 0<r<b where 0<r2<r1 where 0<r3<r2

125 87 38 11 5

Thus, we find that GCD (125, 87) =1. Lets look at one more, GCD (125,20) 125 20 =6*20+5 =4*5

Pseudo code:

GCD (x, y) where x > y > 0

{ a = x;

b = y; while (b>0) { q = a/b; r = a (q*b); a = b; b = r; } GCD = a; }

One of the consequences of the Euclidean algorithm is as follows: Given integers a and b, there is always an integral solution to the equation ax+by=gcd(a,b) Furthermore, the extended Euclidean algorithm can be used to find values of x and y to satisfy the equation above. Consider writing down the steps of Euclids algorithm: a=q1b+r1, b=q1r1+r2, r1=q3r2+r3, ri=qi+2ri+1+ri+2, . rk-2=qkrk-1+rk, rk-1=qk+1rk Consider solving the second to last equation for rk. we get, rk=rk-2 qkrk-1, or GCD (a,b) = rk-2 qkrk-1 Now, solve the previous equation for rk-1: rk-1 = rk-3 qk-1k-2 And substitute this value into the previous derived equation: GCD (a,b) = rk-2 qk(rk-3 qk-1rk-2) GCD (a,b) = (1+qkqk-1) rk2 qkrk-3 where 0<rk<rk-1 where 0<r<b where 0<r2<r1 where 0<r3<r2 where 0<ri+2<ri+1

Note that now we have expressed GCD (a,b) as a linear combination of rk-2 and rk-3. Next we can substitute for rk-2 in terms of rk-3 and rk-4, so that the GCD (a,b) can be expressed as the linear combination of rk-3 and rk-4. Eventually by continuing this process, GCD (a,b) will be expressed as a linear combination of a and b as desire. Find integers x and y such that 135x + 50 y =5 Use Euclids algorithm to compute GCD(135,50): 135 50 35 15 =2*50+35 =1*35+15 =2*15+5 =3*5

Now, lets use the extended Euclidean algorithm to solve the problem: 5=35-2*15, from the second to last equation 35=2*15+5 But, we have that 15=50 35, from the third to last equation 50 = 1*35+15 Now, substitute this value into the previously derived equation: 5 = 35 2*(50-35) 5= 135 2 * 50 Now, finally use the first equation to determine an expression for 35 as a linear combination of 135 and 50. 35 = 135 2 * 50 ; Plug this into our last equation, 5 = 3 * (135 2 * 50 ) 2 * 50 5 = 3 * 135 8 * 50 So, a set of solutions to the equation is x=3, y=8.

Pseudo code:

ComputeInverse(b, c) { old1 = 1,old2 = 0; new1 = 0,new2 = 1; b = b,c = c; r = 2; while (r>1) { q = (b/c); r = b % c; temp1 = old1 new1*q; old1 = new1; new1 = temp1; temp2 = old2 new2*q; old2 = new2; new2 = temp2; b = c; c = r; } return(new2) // b*new1+c*new2 }

CONCLUSION: Extended Euclidean algorithm has been implemented successfully using JAVA language.

- LCM and HCF Tricks, Problems and Formulas _ Bank Exams TodayUploaded byKunal Malhotra
- 134_Sample_Chapter.pdfUploaded byPrince Sharma
- SuperblocksUploaded by51p
- a453guidancedocumentsUploaded byapi-253559971
- gcdUploaded byraul
- IB-09limits(41-47)Uploaded byeamcetmaterials
- Contoh SoalUploaded bySarita Anindita
- 2012 Tut 4 on APGP (Soln for Sect C and D)Uploaded bySamuel
- eucliUploaded bysreedeviish
- Algorithms and FlowchartUploaded byRonelAballaSauza
- Harnessing Sensor NetworksUploaded byajitkk79
- Basic AlgebraUploaded byAdarsh Ron
- scimakelatex.20425.xxx6Uploaded byborlandspam
- Book References and Topper SpeakUploaded byNitin Nilesh
- Best Book for Each SubjectUploaded byNitin Nilesh
- Decoupling IPv4 from Public-Private Key Pairs in Neural NetworksUploaded byLuke Allan
- ENGG407_Ch1_1 Numerical methods lecture oneUploaded byStella Cheng
- Number Theory UNSOLVEDUploaded byShu Shujaat Lin
- scimakelatex.16087.Terry+GuUploaded byAndrewHung
- 7-5.solution.pdfUploaded byDaniel Bastos Moraes
- MaddyUploaded byCarlo Cellucci
- On the Relation Between Summations and Tetrahedral NumbersUploaded byMarco Ripà
- pdf topic 5 6 multUploaded byapi-420649006
- c Lab ManualsUploaded byVivekananda Ganjigunta Narayana
- 405-11Uploaded bysheen
- Notes for a Course on Proofs - Student VersionUploaded byAnonymous F2KP8p
- 12-148-1-PB(1).pdfUploaded byetet100
- Opt Book Ch1Uploaded byM.asif
- Applied Numerical Methods Syl Lab UsUploaded byHaritha Rk
- Design and Analysis of Diagnosis Systems Using Structural MethodsUploaded bythkhung

- Hydrocarbon vision 2025Uploaded byAbhimanyu Singh Hada
- E&P Cos Risk Aversion Means Less ActivityUploaded byAbhimanyu Singh Hada
- CSAT 2011 Reference BooksUploaded byankitt000
- Mannai CorporationUploaded byAbhimanyu Singh Hada
- Hydro Carbon Vision-2025Uploaded byAbhimanyu Singh Hada
- [Strategy] RAS 2013 Prelims_ Booklist, Study Material, Approach, Cutoffs, Previous Papers, Syllabus of Rajasthan State & Subordinate Services Combined Competitive Exam - MrunalUploaded byAbhimanyu Singh Hada
- financial managementUploaded byAbhimanyu Singh Hada
- Dissertation LR TitleUploaded byAbhimanyu Singh Hada
- OceaniaUploaded byAbhimanyu Singh Hada
- open_sslUploaded byAbhimanyu Singh Hada
- Jurong RefineryUploaded byAbhimanyu Singh Hada
- NOBEL PRIZEUploaded byAbhimanyu Singh Hada

- Parse's Human BecomingUploaded byJolas Santos
- Reading Comprehension Test and rpp.docxUploaded byElsa Setiawati
- Cadence EDI System What's New 12.0.pdfUploaded byStudent
- Data Warehouse ConceptsUploaded byShahnawaz Khan
- melinda dwyer- educational autobiographyUploaded byapi-272664977
- cccam 2.2.1 cfgUploaded byerevus1
- Flat EarthUploaded byJim Kat
- Knowledge representation reasoning and declarative problem solving with Answer sets - Chitta Baral.pdfUploaded byEdquel Bueno Prado Farias
- WEBER & Rinne TestsUploaded byBen DeMora
- dhcp-xe-3s-book.epubUploaded byLalo Lalo
- Example of SpivakUploaded byramlohani
- Phase 5 a PlanningUploaded byCharlene Vu
- 1 ModifiedUploaded bydonkalonk
- English Vocabulary Organiser With KeyUploaded byPermento Lacrane
- L1 V5 21 PolDoc HMI Tool Overview G 01Uploaded byCarlos-AugustoVictorious
- Socket Programming using CUploaded byGopal Sharma
- Allen BradleyUploaded byNorasad Rafiq Lim Saari
- 05-decide-4pUploaded bysamreen36
- Steiner&GoldenDawnUploaded byOmorogah Hagmo
- Islcollective Word Order Adjectives 237724dbc427cb9adf4 65525342Uploaded byWebfrit
- CM42 PH Manual Part2 EngUploaded bymykillerdrone
- 3nd4Uploaded byAkhil Joseph George
- Faiz Ahmad Faiz, Sain Sucha-Memory_ Poetry of Faiz Ahmad Faiz-Vudya Kitaban Forlag (1987).pdfUploaded byAhmad Jan
- zp_bankUploaded byshark
- Activity 2 - Pre-knowledge Online Activity DianaUploaded bydiana enriquez lopez
- AntifonarioUploaded bykexakalu
- Avaya One-X Communicator Client R6 2 FP6 GA Release NotesUploaded byFabio Luis Braceiro
- unit 1 project listUploaded byapi-293873398
- theory comparisonUploaded byapi-241899532
- Carl Schmitt's Fear, Nomos-Norm-Network_Ino AugsbergUploaded byAnonymous eDvzmv