Jump to content

Numbers divisible by their individual digits, but not by the product of their digits.: Difference between revisions

(→‎OCaml: add)
Line 8:
=={{header|11l}}==
{{trans|Python}}
 
<syntaxhighlight lang="11l">F p(n)
‘True if n is divisible by each of its digits,
Line 356 ⟶ 355:
<pre>22 33 44 48 55 66 77 88 99 122 124 126 155 162 168 184 222 244 248 264 288 324 333 336 366 396 412 424 444 448 488 515 555
636 648 666 728 777 784 824 848 864 888 936 999</pre>
=={{header|Arturo}}==
 
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">valid?: function [n][
digs: digits n
Line 1,279 ⟶ 1,278:
424 444 448 488 515 555 636 648 666
728 777 784 824 848 864 888 936 999</pre>
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let test b x =
let rec loop m n =
if n < b
then x mod n = 0 && x mod (m * n) > 0
else let d = n mod b in d > 0 && x mod d = 0 && loop (m * d) (n / b)
in loop 1 x
 
let () =
Seq.ints 1 |> Seq.take 999 |> Seq.filter (test 10)
|> Seq.iter (Printf.printf " %u") |> print_newline</syntaxhighlight>
{{out}}
<pre> 22 33 44 48 55 66 77 88 99 122 124 126 155 162 168 184 222 244 248 264 288 324 333 336 366 396 412 424 444 448 488 515 555 636 648 666 728 777 784 824 848 864 888 936 999</pre>
 
=={{header|Pascal}}==
Line 1,566 ⟶ 1,579:
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="quackery"> [ dup 0 = iff
[ 2drop false ] done
Line 1,596 ⟶ 1,608:
 
=={{header|Raku}}==
 
<syntaxhighlight lang="raku" line>say "{+$_} matching numbers:\n{.batch(10)».fmt('%3d').join: "\n"}" given
(^1000).grep: -> $n { $n.contains(0) ?? False !! all |($n.comb).map($n %% *), $n % [*] $n.comb };</syntaxhighlight>
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.