Skip to content
← All questions

Why does the program outputting only asterisks prove the gcd equality holds?

The program iterates through a range of integer values for k and checks if gcd(a,b) is not equal to gcd(b, a−k∗ba-k*b). If the equality fails for any k, it prints that k. Since the program only outputs asterisks (a completion marker) and no k values, it indicates that no counterexamples were found in the tested range, supporting the claim that the equality holds for those k.

Conditions

  • The code tests k from -1024 to 1024.
  • The condition `c != gcd(b, a−k∗ba - k * b)` is checked for each k.

Reasoning, step by step

  1. Initialize a=24a=24, b=504b=504, and c=gcd(a,b).
  2. Loop k from -1024 to 1024.
  3. Inside the loop, check if c is not equal to gcd(b, a−k∗ba-k*b).
  4. If they are not equal, print k.
  5. After the loop, print asterisks.
  6. 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, a−k∗ba - k * 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

Meet the concept

↗
Find a method

↗
Find a method

↗
Find a method

↗
Meet the concept

↗

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.