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

Added 11l
No edit summary
(Added 11l)
Line 5:
<br>where &nbsp; <big>'''n &nbsp; &lt; &nbsp; 1,000''' </big>
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F p(n)
‘True if n is divisible by each of its digits,
but not divisible by the product of those digits.
V digits = String(n).map(c -> Int(c))
R !(0 C digits) & (0 != (n % product(digits))) & all(digits.map(d -> 0 == @n % d))
 
F chunksOf(n)
‘A series of lists of length n, subdividing the
contents of xs. Where the length of xs is not evenly
divible, the final list will be shorter than n.
F go(xs)
R ((0 .< xs.len).step(@=n).map(i -> @xs[i .< @=n + i]))
R go
 
V xs = (1..999).filter(n -> p(n)).map(String)
V w = xs.last.len
print(xs.len" matching numbers:\n")
print(chunksOf(10)(xs).map(row -> row.map(cell -> cell.rjust(:w, ‘ ’)).join(‘ ’)).join("\n"))</lang>
 
{{out}}
<pre>
45 matching numbers:
 
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|8086 Assembly}}==
1,481

edits