Problem: Imagine a sequence
1504170715041707*n mod 4503599627370517 where
n is an integer increasing from 1. Find the subsequence of this sequence where every next element is smaller than the previous one.
All the solutions I've read about include brute force calculations. I found a better one, and I can't stop myself from posting it.