Project Euler 111 - Primes with Runs

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

Note: Code runs in~350 seconds, too slow!

Thought Process

I have done a bit too many counting problems recently, so although I'm not happy with my solution since it's just brute force I don't care too much.

My idea is simple, given an n-digit number and d our repeating digit, I simply tested all possible numbers. The way I do this is to calculate S(n, d) as follows:

Interactive Code

Input 2 integers with a space between (n, d)

Code will output S(n, d)