[Verse 1]
When you see ax congruent b mod n
Don't just guess, there's rules to comprehend
Check the greatest common divisor first
Does it split b clean, or will hopes be cursed?
GCD of a and n must divide b true
Or no solution waits there for you
[Chorus]
Linear congruences have their key
GCD divides b, then solutions you'll see
Count them carefully, d in total appear
Modulo n, the pattern's crystal clear
When GCD is one, there's just one way
Extended Euclidean saves the day
[Verse 2]
If d equals gcd and b won't divide
Then pack your bags, no answer can hide
But when it splits evenly, magic unfolds
Exactly d solutions the theorem holds
Modulo n they scatter and spread
Following patterns mathematicians have read
[Chorus]
Linear congruences have their key
GCD divides b, then solutions you'll see
Count them carefully, d in total appear
Modulo n, the pattern's crystal clear
When GCD is one, there's just one way
Extended Euclidean saves the day
[Bridge]
Special case when gcd is one
Unique solution, nowhere to run
Find a inverse, the algorithm's friend
Multiply by b, watch problems end
X congruent a inverse times b
Modulo n sets the answer free
[Verse 3]
Extended Euclidean works its charm
Finds the inverse, keeps you from harm
Backward substitution, coefficients align
Until a inverse emerges, perfectly fine
Multiply by b and take modulo
Your unique solution's ready to show
[Chorus]
Linear congruences have their key
GCD divides b, then solutions you'll see
Count them carefully, d in total appear
Modulo n, the pattern's crystal clear
When GCD is one, there's just one way
Extended Euclidean saves the day
[Outro]
Remember the rule when equations call
GCD must divide or there's none at all
Count your solutions, they number d
Linear congruences set logic free