I got the answer from a friend but its very confusing to me. So I wanted to create a simpler answer to it. Thanks in advance. Here is the code he made:
n=int(inpu