Project Euler 697 - Randomly Decaying Sequence

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

Note: This problem is not suitable for hints!!