1 / 4

Euclid Algorithm: GCD

Euclid Algorithm: GCD. GCD:. Input integers a,b;. Step 1:. If a  b. then X  a, Y  b;. else X  b, Y  a;. Step 2:. Z  the remainder of X  Y;. Step 3:. If Z = 0. then the GCD is Y;. else X  Y, Y  Z,. do steps 2, 3 again. Problem Solved. On integers. On what?.

nova
Download Presentation

Euclid Algorithm: GCD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Euclid Algorithm: GCD GCD: Input integers a,b; Step 1: If a  b then X  a, Y  b; else X  b, Y  a; Step 2: Z  the remainder of X  Y; Step 3: If Z = 0 then the GCD is Y; else X  Y, Y  Z, do steps 2, 3 again. Problem Solved

  2. On integers. On what? Addition In general, we have 3 numbers involved. So, we need three places to hold the numbers. dec a 2 dec b 2 dec c 2 int a,b,c; a=1,b=3 move a R1 move b R2 addR1R2 moveR2 c 1111 0011 0010 0001 1111 0011 1101 0010 1010 010000010010 1111 00110010 1100 c=a+b; now, c=4

  3. ProblemsSolutions cycle ?? System analyst, Project leader Problems Programmers Algorithms Programs in C++ (High level Programming Language) compiler Assembly Assembler Machine code computer Results

  4. OOP (Object-oriented Programming) A new programming paradigm after ’80s. Problem solving  Procedure finding But Why should I have to write the same procedure to do the same job over and over again? Fact: Different problems usually consist of many common smaller problems.

More Related