Introduction
A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent question "Speed of Lobsters". The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are left with just the factor.
Example: 51375
is a lobster number, since its prime factors are [3,5,137]
, which can be made by lobsters thusly: [**3**, 5**** / ****5, *137*]
. Another lobster number is 62379
, as the factors [3,29,239]
can be formed as [**3**,*2**9,*23*9]
.
Challenge
Given a number as input, return whether it is a lobster number or not. Preferentially this is a boolean output, such as 1 or 0, or True or False.
Astute readers may realize that prime numbers are a trivial solution to this requirement, but since they don't allow the lobsters to eat any digits, they are out. Your program must not identify prime numbers as lobster numbers.
This is similar to OEIS A035140, but has the additional requirement that each digit of the factor must appear at least the same number of times in the number, and in the correct order. In other words, 132
is not a lobster number, since its factors are [2,3,11]
, and the 11
cannot be made by munching away at just 132
. 312
is also not a lobster number, because its factors are [2,3,13]
, and 13
is out of order.
I believe the "mathematical" definition would be: "Determine if the number n is a composite number such that all prime factors of n are a subsequence of n".
Test Cases
59177 -> True
62379 -> True
7 -> False
121 -> True
187 -> False
312 -> False
As always, Standard Loopholes are forbidden.
Note:
It has come to my attention that the original reasoning I gave for not needing to handle 0 or 1 as input is faulty. However, requiring the proper output at this point would invalidate a number of answers. Therefore, let it hereby be known that neither 0 nor 1 are lobster numbers, but you also do not need to handle them as input (they are not valid test cases). If your code does handle them correctly, you may give yourself the Lobster Advocate Badge™.