Munchausen numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|ALGOL W}}: Fixed typos in comments)
m (→‎{{header|Pascal}}: added Combinations_with_repetitions)
Line 425: Line 425:
{{works with|Free Pascal}}
{{works with|Free Pascal}}
{{works with|Delphi}}
{{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.
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.
So I only have to create [http://rosettacode.org/wiki/Combinations_with_repetitions Combinations_with_repetitions] and 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 combination 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