Munchausen numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|langur}}: change where() to filter())
(→‎OCaml: add)
Line 19: Line 19:
=={{header|11l}}==
=={{header|11l}}==
{{trans|Python}}
{{trans|Python}}

<syntaxhighlight lang="11l">L(i) 5000
<syntaxhighlight lang="11l">L(i) 5000
I i == sum(String(i).map(x -> Int(x) ^ Int(x)))
I i == sum(String(i).map(x -> Int(x) ^ Int(x)))
Line 567: Line 566:
<pre>1
<pre>1
3435</pre>
3435</pre>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">Loop, 5000
<syntaxhighlight lang="autohotkey">Loop, 5000
Line 1,356: Line 1,356:


=={{header|Fōrmulæ}}==
=={{header|Fōrmulæ}}==

Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.


Line 1,463: Line 1,462:


=={{header|J}}==
=={{header|J}}==

Here, it would be useful to have a function which sums the powers of the digits of a number. Once we have that we can use it with an equality test to filter those integers:
Here, it would be useful to have a function which sums the powers of the digits of a number. Once we have that we can use it with an equality test to filter those integers:


Line 1,532: Line 1,530:


=={{header|JavaScript}}==
=={{header|JavaScript}}==

===ES6===
===ES6===


Line 1,874: Line 1,871:
<pre>1
<pre>1
3435</pre>
3435</pre>

=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let is_munchausen n =
let pwr = [|1; 1; 4; 27; 256; 3125; 46656; 823543; 16777216; 387420489|] in
let rec aux x = if x < 10 then pwr.(x) else aux (x / 10) + pwr.(x mod 10) in
n = aux n

let () =
Seq.(ints 1 |> take 5000 |> filter is_munchausen |> iter (Printf.printf " %u"))
|> print_newline</syntaxhighlight>
{{out}}
<pre> 1 3435</pre>


=={{header|Pascal}}==
=={{header|Pascal}}==
Line 2,067: Line 2,076:
3435
3435
438579088</pre>
438579088</pre>



=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
Line 2,343: Line 2,351:


=={{header|Quackery}}==
=={{header|Quackery}}==

<syntaxhighlight lang="quackery"> [ dup 0 swap
<syntaxhighlight lang="quackery"> [ dup 0 swap
[ dup 0 != while
[ dup 0 != while
Line 2,359: Line 2,366:


=={{header|Racket}}==
=={{header|Racket}}==

<syntaxhighlight lang="text">#lang racket
<syntaxhighlight lang="text">#lang racket


Line 2,670: Line 2,676:


=={{header|VBA}}==
=={{header|VBA}}==

<syntaxhighlight lang="vb">
<syntaxhighlight lang="vb">
Option Explicit
Option Explicit