How to resolve the algorithm Munchausen numbers step by step in the Factor programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Munchausen numbers step by step in the Factor programming language

Table of Contents

Problem Statement

A Munchausen number is a natural number n the sum of whose digits (in base 10), each raised to the power of itself, equals n. (Munchausen is also spelled: Münchhausen.) For instance:   3435 = 33 + 44 + 33 + 55

Find all Munchausen numbers between   1   and   5000.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Munchausen numbers step by step in the Factor programming language

Source code in the factor programming language

USING: kernel math.functions math.ranges math.text.utils
prettyprint sequences ;

: munchausen? ( n -- ? )
    dup 1 digit-groups dup [ ^ ] 2map sum = ;

5000 [1,b] [ munchausen? ] filter .


  

You may also check:How to resolve the algorithm The Twelve Days of Christmas step by step in the Python programming language
You may also check:How to resolve the algorithm Anti-primes step by step in the Quackery programming language
You may also check:How to resolve the algorithm Chowla numbers step by step in the Python programming language
You may also check:How to resolve the algorithm ABC problem step by step in the SPAD programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Common Lisp programming language