113k views
4 votes
FIND GCD USING CONSECUTIVE INTEGER CHECKING ALGORITHM DESCRIPTION

Consecutive Integer Checking Algorithm also solves the problem of finding the greatest common divisor of two non-negative, non-zero integers. You will create a program that will calculate the greatest common divisor of two integers based on the Consecutive Integer Checking Algorithm.

User Rob Fisher
by
8.0k points

1 Answer

2 votes

Final answer:

The Consecutive Integer Checking Algorithm finds the GCD of two integers by checking consecutively from the smaller number down to 2 for a common divisor. If none is found, the GCD is 1.

Step-by-step explanation:

Consecutive Integer Checking Algorithm for GCD

The Consecutive Integer Checking Algorithm is a method used to find the Greatest Common Divisor (GCD) of two non-negative, non-zero integers. This algorithm involves checking integers consecutively from the smallest of the two given numbers down to 2 (inclusive) to find the largest integer that divides both numbers without leaving a remainder. Here is a step-by-step explanation of the algorithm:

  1. Identify the smaller number of the two given integers.
  2. Starting from this smallest number, check each integer to see if it divides both of the given numbers without leaving a remainder.
  3. If you find a number that divides both, that number is the GCD.
  4. If no number is found by the time you reach 2, then the GCD is 1, since 1 divides any integer.

For example, to find the GCD of 48 and 18, we would start at 18 (the smaller number) and work down. We would find that 6 is the largest number that divides both 48 and 18, hence 6 is the GCD.

User Mikel Tawfik
by
8.3k points