Munchausen numbers: Difference between revisions

m (→‎{{header|langur}}: change where() to filter())
(→‎OCaml: add)
Line 19:
=={{header|11l}}==
{{trans|Python}}
 
<syntaxhighlight lang="11l">L(i) 5000
I i == sum(String(i).map(x -> Int(x) ^ Int(x)))
Line 567 ⟶ 566:
<pre>1
3435</pre>
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">Loop, 5000
Line 1,356:
 
=={{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.
 
Line 1,463 ⟶ 1,462:
 
=={{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:
 
Line 1,532 ⟶ 1,530:
 
=={{header|JavaScript}}==
 
===ES6===
 
Line 1,874 ⟶ 1,871:
<pre>1
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}}==
Line 2,067 ⟶ 2,076:
3435
438579088</pre>
 
 
=={{header|PicoLisp}}==
Line 2,343 ⟶ 2,351:
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="quackery"> [ dup 0 swap
[ dup 0 != while
Line 2,359 ⟶ 2,366:
 
=={{header|Racket}}==
 
<syntaxhighlight lang="text">#lang racket
 
Line 2,670 ⟶ 2,676:
 
=={{header|VBA}}==
 
<syntaxhighlight lang="vb">
Option Explicit
559

edits