## Project Euler 87: Investigating numbers that can be expressed as the sum of a prime square, cube, and fourth power

#### Project Euler 87 Problem Description

The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way:

28 = 2^{2} + 2^{3} + 2^{4}

33 = 3^{2} + 2^{3} + 2^{4}

49 = 5^{2} + 2^{3} + 2^{4}

47 = 2^{2} + 3^{3} + 2^{4}

How many numbers below fifty million can be expressed as the sum of a prime square, prime cube, and prime fourth power?

#### Analysis

This is a problem that brute force solves so quickly and easily that much more investigation is hardly warranted. It’s not obvious that any other approach would produce a much faster solution.

Basically, this routine generates a list of prime numbers and considers candidates for the square root, cube root and fourth root of the limit. Then we iterate over the lists and calculate unique numbers below 50,000,000 as p_{2}^{2} + p_{3}^{3} + p_{4}^{4}, where p_{2}, p_{3},and p_{4} are prime numbers. The length of the set is the how many discrete sets fit the criteria.

#### Project Euler 87 Solution

Runs < 0.360 seconds in Python 2.7.Use this link to get the Project Euler 87 Solution Python 2.7 source.

#### Afterthoughts

- Runs for 1,409,343 iterations.

*Project Euler 87 Solution last updated*

from Euler import prime_sieve as sieve

How to get above line work. No module found for me.

https://blog.dreamshire.com/common-functions-routines-project-euler/#prime_sieve

You can find all the useful functions we use on this page.