Putnam Math Competition (2016) Solution for Problem B-4

Problem:

Putnam Problem B-4

Reference: https://kskedlaya.org/putnam-archive/2016.pdf


Here's my solution to this problem:

This solution was inspired by the elegant approach of Professor Manjul Bhargava. His original solution appears in the official 2016 Putnam archive, which can be accessed here.