Problem 59701. Express numbers as the sum of a prime, a square, and a cube

While traveling on an interstate highway, I noticed a sign that gave distances to three places. The distances were 3, 8, and 9 miles, or a prime, a perfect cube, and a perfect square. I then wondered whether it was possible to express integers (above a certain value) as the sum of a prime, a square, and a cube. For example, 11 can be expressed as 2+1+8 = 2+1^2+2^3, and 17 can be expressed as 5+4+8 = 5 + 2^2+2^3 or 7+9+1 = 7+3^2+1^3.
Write a function to list ways to express numbers as the sum of a prime, a square, and a cube. All three must be positive. The function should return a matrix the primes in the first column, the squares in the second, and the cubs in the third, and the rows should be sorted by the first column and then the second. Given an input of 11, the function should return [2 1 8], and given an input of 17, the function should return [5 4 8; 7 9 1]. If the input cannot be expressed in this way, return the empty vector [].
Optional: Prove that all integers greater than 6 can be expressed as the sum of a prime, a square, and a cube.

Solution Stats

40.0% Correct | 60.0% Incorrect
Last Solution submitted on Mar 31, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author268

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!