Project Euler 647 - Randomly Decaying Sequence

Official link: https://projecteuler.net/problem=647