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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Munchausen numbers step by step in the Craft Basic 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 Craft Basic programming language

Source code in the craft programming language

for i = 0 to 5

	for j = 0 to 5

		for k = 0 to 5

			for l = 0 to 5

				let m = int(i ^ i * sgn(i))
				let m = m + int(j ^ j * sgn(j))
				let m = m + int(k ^ k * sgn(k))
				let m = m + int(l ^ l * sgn(l))

				let n = 1000 * i + 100 * j + 10 * k + l

				if m = n and m > 0 then

					print m

				endif

				wait

			next l

		next k

	next j

next i


  

You may also check:How to resolve the algorithm FizzBuzz step by step in the Metafont programming language
You may also check:How to resolve the algorithm Idiomatically determine all the characters that can be used for symbols step by step in the Factor programming language
You may also check:How to resolve the algorithm HTTPS/Authenticated step by step in the Python programming language
You may also check:How to resolve the algorithm Flatten a list step by step in the NewLISP programming language
You may also check:How to resolve the algorithm Approximate equality step by step in the Haskell programming language