Why does the program outputting only asterisks prove the gcd equality holds?
Conditions
- The code tests k from -1024 to 1024.
- The condition `c != gcd(b, )` is checked for each k.
Reasoning, step by step
- Initialize , , and c=gcd(a,b).
- Loop k from -1024 to 1024.
- Inside the loop, check if c is not equal to gcd(b, ).
- If they are not equal, print k.
- After the loop, print asterisks.
- Observe that only asterisks are printed, meaning the condition never triggered.
Example
The terminal output shows only `**********`, with no k values printed, indicating that `c == gcd(b, )` held true for all tested k.
Common misconceptions
- Believing that the absence of output means the program did not run; the asterisks confirm execution.
- Thinking that testing a finite range proves the formula for all infinite integers; it only provides empirical support for the tested range.
Watch the explanation
Connected concepts
Explore next
Related questions
Yes, in this context, "greatest common factor" is being used for what is more commonly called the greatest common divisor in many modern texts. The mathematical procedure shown is the same subtraction-based Euclidean algorithm.
Conditions: Used informally in the explanation of why the algorithm works.
To find the GCF by listing factors, list all positive factors of the first number, list all positive factors of the second number, identify the factors that appear in both lists, and select the largest number from the common factors.
Conditions: The inputs are positive integers.; Listing is practical for the small examples; it is not asserted to be the fastest method.
To start the Euclidean algorithm for , you write the larger number as the smaller number multiplied by an unknown quotient plus an unknown remainder. Specifically, you set up the division equation .
Conditions: The inputs are positive integers.; The larger number is placed on the left-hand side of the equation.; The quotient is an integer and the remainder satisfies .
To find the greatest common divisor of two large numbers, repeatedly apply the division-with-remainder step. Start by dividing the larger number by the smaller number.
Conditions: The inputs are two positive integers.; The division algorithm is applied at each step.; The process stops when a remainder equals 0.
The speaker verbally says "greatest common denominator," but the mathematical notation on the board is "gcd," which conventionally stands for "greatest common divisor." The context of dividing integers to find a common factor confirms that the intended concept is the greatest common divisor, and the spoken word is a verbal slip.
Conditions: The video discusses finding the common factor of two integers.; The board displays the notation gcd(a;b).; The procedure involves repeated integer division.
Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.