A number is called a factorion if it is equal to the sum of the factorials of its digits. For example, 145 is a factorion since 145 = 1! + 4! + 5! (Remember that n! is the fancy, mathematical way of denoting the factorial of n, which is the product of all of the numbers from 1 to the number n.) Another, relatively simpler example of a factorion is 2, since 2 is equal to 2! (we're not exclaiming there.) The next few exercises about these numbers can be found under the "Factorions" sprite in the starter file. For all of the blocks on this page, you should use higher-order functions in your solution. You cannot use explicit recursion or the yellow and orange loop constructs (such as repeat, repeat until, and for); you can, however, use the built-in list blocks in the Variables tab and the HOF blocks from "import tools." You will find the blocks that you created on the last page useful.
Create the block
that checks if a number satisfies the definition above. The block should, for example, report true
for:
and false
for:
To do this, you'll need the factorial
block. This time, write it using HOFs, rather than recursion.
Using the block you created above, create the block
that lists all the factorions between the first and second inputs, inclusive. For example,
should report