We need a way to quickly check prime factors of this massive number, we can use the below fact, and the python pow function to handle this quite easily. All that is left is to generate a bunch of primes and test until we find 40. See Essential Functions for my prime generation function.
Enter a number (yourinput)
Code will output the sum of the first yourinput prime factors of R(10^9)