Note: This is a past question from Brilliant.org
I was recently thinking about how to write a program which fetches you the number of 4-term geometric progressions consisting of positive integers under 100. I solved this problem on a website called Brilliant.org by considering the common ratios and the first terms, and got the right answer (which I don't want to disclose because they do use past questions again and again).
I want to learn how to write a program which solves this question, which I'd again write for clarity:
What is the number of 4-term geometric progressions consisting entirely of positive integers less than or equal to 100?
Any language, preferably Sage, would work for me. I'd appreciate it if you write a pseudocode.
Bruteforce approach works well for numbers $\leq 100$. Try the following Haskell one-liner:
or this one in python (which is the base language of Sage):
I hope this helps ;-)