Munchausen numbers: Difference between revisions
Content added Content deleted
m (→{{header|Pascal}}: more explanation, hopefully no obfuscation ;-)) |
Walterpachl (talk | contribs) m (Pascal - fix tags and add an 'e' :-)) |
||
Line 294: | Line 294: | ||
<pre>1 |
<pre>1 |
||
3435</pre> |
3435</pre> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{works with|Free Pascal}} |
|||
{{works with|Delphi}} |
|||
tried to speed things up.Only checking one arrangement of 123456789 instead of all 9! = 362880 permutations. |
tried to speed things up.Only checking one arrangement of 123456789 instead of all 9! = 362880 permutations. |
||
This ist possible, because summing up is commutative.So I only need to check, that the number and the sum of power of digits have the same amount in every possible digit.This means, that a permutation of the digits of number leads to the sum of power of digits. |
This ist possible, because summing up is commutative.So I only need to check, that the number and the sum of power of digits have the same amount in every possible digit. This means, that a permutation of the digits of number leads to the sum of power of digits. Therefore I need leading zero's. |
||
<lang pascal>{$IFDEF FPC}{$MODE objFPC}{$ELSE}{$APPTYPE CONSOLE}{$ENDIF} |
<lang pascal>{$IFDEF FPC}{$MODE objFPC}{$ELSE}{$APPTYPE CONSOLE}{$ENDIF} |
||
uses |
uses |