Talk:Munchausen numbers

From Rosetta Code

0 to the power 0 is considered as 0 for Munchausen numbers

...according to the Wikipedia page - might be worth mentioning in the task as it is normally 1 according to mathematicians. --Tigerofdarkness (talk) 18:25, 23 September 2016 (UTC)

This changes the output only for the number 0 which is not between 1 and 5000 (the task's requirement) --Walterpachl (talk) 19:16, 23 September 2016 (UTC)
True, it would only be an issue if anyone tried to extend this to the next Munchausen number (438 579 088 - also the last known one it seems). --Tigerofdarkness (talk) 21:12, 23 September 2016 (UTC)
Also, if you are using an algorithm where the digits are already split up (so not derived by using mod and division), you don't have to worry about leading zeros e.g. 0030 is "Munchausen" if 0^0 = 1. The non-standard 0^0 = 0 simplifies things. --Tigerofdarkness (talk) 21:55, 23 September 2016 (UTC)
Where would those leading zeros come from? --Rdm (talk) 00:33, 24 September 2016 (UTC)
See the current ALGOL 68 sample which holds the 4 digits as separate numbers and indexes a table of powers - the non-standard 0^0 allows indexing the table of powers without having to worry whether the digit is a leading zero or not. The sample does this to avoids any multiplication, division or modulo operations. --Tigerofdarkness (talk) 19:51, 24 September 2016 (UTC)
Ok, so it's a hack that lets the programmer use a fixed width array of digits without having to bother with the relevant array length. --Rdm (talk) 20:22, 24 September 2016 (UTC)
Or it's a feature of the definition that can be exploited :) --Tigerofdarkness (talk) 09:40, 25 September 2016 (UTC)
How is that any different? Rdm (talk) 09:48, 25 September 2016 (UTC)

I would like to point out that +438579088, in the Algol60 output is not correct...

 +/ x * x ← 4 3 8 5 7 9 0 8 8

438579089 Note that is APL so * is exponentiation not multiplication.

APL I'm sure, will be using the mathematical definition of exponentiation where 0^0 is defined to be 1. As the title of this section of this discussion page indicates, Munchausen numbers use an alternative definition of 0^0 = 0 ( being vaguely from a mathematical background, I thought it was worth highlighting it ).
If you use 0^0 = 1, there are only two Munchausen numbers, 1 and 3435. If you use 0^0 = 0, there are four: 0, 1, 3435 and 438579088.
I see the Wikipedia page (Perfect digit-to-digit invariant) now discusses Munchausen numbers using either convention, as does the Mathworld page (which spells Munchhausen with two h letters).
There are a number of other language samples for this task that show the four Munchausen numbers, including Java, Kotlin and Pascal.
Incidentally, there currently isn't an Algol 60 sample, the language you are singling out for criticism is Algol 68 :)
BTW, please sign your posts.
--Tigerofdarkness (talk) 20:00, 17 August 2023 (UTC)