Problem 61167. Gather primes

A book titled Gather that I regularly see inspired this game: make as many words as possible from the letters in the word GATHER, using each letter at most once. A list of words could include A, AH, AT, EH, HA, HE, ARE, AGE, ARE, ART, ATE, EAR, EAT, ERA, ERG, ETA, GAR, GAT, GET, HAT, HER, RAG, RAH, RAT, TAG, TAR, TEA, THE, GATE, HART, HATE, HEAT, RATE, RHEA, TARE, TEAR, EARTH, GRATE, GREAT, HEART, and possibly others, depending on the dictionary one uses.
Less subjective would be to play this game with prime numbers. That is, take an n-digit number and—using each digit at most once—make as many prime numbers of 1 digit, 2 digits, 3 digits, etc. up to n digits. For example, starting with 13 would lead to 3, 13, and 31, and starting with 7103 would lead to 3, 7, 13, 17, 31, 37, 71, 73, 103, 107, 137, 173, 307, 317, 701, 1307, 3701, 7013, and 7103.
Write a function to list the primes (in increasing order) that can be made from the digits of a number.

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Jan 19, 2026

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author320

Problem Tags

Community Treasure Hunt

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

Start Hunting!