This was one of my favorite Project Euler problems, but getting to the mathematical solution admittedly took me a couple of weeks.

Perhaps because I was pigeon-holing this as a programming optimization problem.

I wrote about it too! [0]

[0] https://nmn.gl/blog/vibe-coding-gambling