title: Is it a Lynch-Bell number?

text:
# Question
Title: Is it a Lynch-Bell number?
You will be given a positive, whole number (that will never contain a 0) as input. Your task is to check whether it is a Lynch-Bell number or not.

A number is a Lynch-Bell number if all of its digits are unique and the number is divisible by each of its digits.

In fact, there are actually only 548 Lynch-Bell numbers, so hard-coding is a possibility, but will almost certainly be longer.

126 is a Lynch-Bell number because all of its digits are unique, and 126 is divisible by 1, 2, and 6.

You can output any truthy and falsy value.

## Examples:

```
7 -> truthy
126 -> truthy
54 -> falsy
55 -> falsy
3915 -> truthy

```

This is OEIS A115569.

# Answer
> 27 votes
## Mathematica, 42 bytes

```
0!=##&@@d&&##&@@((d=IntegerDigits@#)∣#)&

```

I think `0!=##&@@d&&##&@@` is a new low in readability for Mathematica...

### Explanation

Some of the basic syntactic sugar used here:

* `&` has very low precedence and turns everything left of it into an unnamed function.
* `&&` is just the `And` operator.
* `#` is the argument of the nearest enclosing unnamed function.
* `##` is a *sequence* of all of the function's arguments.
* `@` is prefix notation for function calls, i.e. `f@x == f[x]`.
* `@@` is `Apply`, which passes the elements of a list as individual arguments to a function, i.e. `f@@{a,b,c} == f[a,b,c]`.

With that out of the way...

```
(d=IntegerDigits@#)

```

This should be fairly self-explanatory: this gives us a list of the input's decimal digits and stores the result in `d`.

```
(...∣#)

```

This tests the input for divisibility by each of its digits (because the divisibility operator is `Listable`). This gives us a list of `True`s and `False`s.

```
...&@@...

```

We apply the function on the left-hand side to the list of booleans, such that each boolean is a separate argument.

```
...&@@d

```

We apply another function to `d`, so that the individual digits are given as separate arguments. The function is `0!=##&`, i.e. `Unequal[0, d<sub>1</sub>, d<sub>2</sub>, ...]`. It checks that all the digits are distinct (and that they are distinct from `0` but that's given by the challenge, and if it wasn't, it wouldn't be a divisor anyway). `0!=##&` is really just a 1-byte saver on using `Unequal` itself, and it works because there's a 1-byte element (`0`) that we know is not present. So this first thing checks that the digits are unique. Let's call this result `U`

```
...&&##

```

Again, this is really just shorthand for `And[U, ##]`. With `##` being a sequences, the individual booleans from the initial divisibility check are expanded into the `And`, so we get `And[U, d<sub>1</sub>∣n, d<sub>2</sub>∣n, ...]` which checks that both the digits are unique and each digit divides the input.

# Answer
> 11 votes
# Python 3, 56 bytes

```
lambda n:any(int(n)%int(x)for x in n)or len(n)>len({*n})

```

Try it online!

Output `False` if it's IS a Lynch-Bell number, `True` otherwise.

# Answer
> 10 votes
# Jelly, ~~6~~ 4 bytes

```
Dg⁼Q

```

Try it online!

### How it works

```
Dg⁼Q  Main link. Argument: n

D     Decimal; convert n to base 10.
 g    Take the GCD of each decimal digit k and n.
      For each k, this yields k if and only if k divides n evenly.
   Q  Unique; yield n's decimal digits, deduplicated.
  ⁼   Test the results to both sides for equality.

```

# Answer
> 9 votes
# Brachylog, 10 bytes

```
≠g;?z%ᵐ=h0

```

Try it online!

### Explanation

```
≠             All digits are different
 g;?z         Zip the input with each of its digits
     %ᵐ       Map mod
       =      All results are equal
        h0    The first one is 0

```

# Answer
> 6 votes
## JavaScript (ES6), ~~42~~ 41 bytes

```
s=>![...s].some((e,i)=>s%e|s.search(e)<i)

```

Takes input as a string and returns `true` or `false` as appropriate. Edit: Saved 1 byte thanks to @RickHitchcock. Other versions:

Takes input as a string and returns `0` or `1` (i.e. logical inverse) for 40 bytes:

```
s=>/(.).*\1/.test(s)|[...s].some(e=>s%e)

```

Takes input as a number and returns `0` or `1` for 43 bytes:

```
n=>/(.).*\1/.test(n)|[...''+n].some(e=>n%e)

```

Takes input as a number and returns `1` or `0` for 45 bytes:

```
n=>!/(.).*\1/.test(n)&![...''+n].some(e=>n%e)

```

# Answer
> 6 votes
# C#, ~~87~~ 83 bytes

```
using System.Linq;s=>s.Distinct().Count()==s.Length&s.All(c=>int.Parse(s)%(c-48)<1)

```

I wrote this in notepad before testing in Visual Studio, where it worked fine, so just realised I'm now that level of nerd...

Full/Formatted Version:

```
using System;
using System.Linq;

class P
{
    static void Main()
    {
        Func<string, bool> f = s => s.Distinct().Count() == s.Length
                                  & s.All(c => int.Parse(s) % (c - 48) < 1);

        Console.WriteLine(f("7"));
        Console.WriteLine(f("126"));
        Console.WriteLine(f("54"));
        Console.WriteLine(f("55"));
        Console.WriteLine(f("3915"));

        Console.ReadLine();
    }
}

```

# Answer
> 6 votes
# 05AB1E, 4 bytes

```
ÑÃÙQ

```

Try it online!

Same algorithm as this answer to a related question.

# Answer
> 5 votes
# Python 3, 54 bytes

Returns `False` when a number is a Lynch-Bell number. Takes strings as input. Came up with on my own but very similar to Rod's. I would've commented under his post but I don't have any reputation yet.

```
lambda s:len({*s})<len(s)+any(int(s)%int(c)for c in s)

```

Try it online!

# Answer
> 5 votes
# Regex (ECMAScript), ~~194~~ ~~171~~ ~~167~~ ~~164~~ ~~155~~ ~~145~~ ~~142~~ 107 bytes

*-35 bytes (142 → 107) thanks to H.PWiz; this is a complete reimplementation. The primary sources of bytes saved are using* `tail = floor((tail + Digit) / 10) - Digit` *instead of* `tail = floor(tail / 10)` *, and "factoring" the assertions – reusing the expression at the end to mean two different things.*

`^(?!(x{1,9})(((?=(x*)((\1\4){9}x*))\5)*(?=(x*)(\7{9}$))\8\1|(?!\1*$))((?=(x*)((\1\10){9}x*))\11)*(x{10})*$)`

Try it online!

Takes its input in unary, as a sequence of `x` characters whose length represents the number.

This was an interesting challenge to solve without molecular lookahead or variable-length lookbehind. The restrictions result in a completely different algorithm being used.

Note that the above version does not reject numbers that have a zero as at least one of their digits, as per the challenge's rules. It costs ~~2 bytes~~ 10 bytes to handle zero correctly, for a total of **~~144~~ 117 bytes**:

`^(?!(x{0,9})(((?=(x*)((\1\4){9}x*))\5)*(?=(x*)(\7{9}$))\8\1|(?!\1*$))((?=(x*)((\1\10){9}x*))\11)*((x{10})+|(?!\1))$)x`

Try it online!

The commented version below describes the **~~144~~ 117 byte** version:

```
^           # tail = N = input number
(?!         # Negative lookahead - Assert that there's no way for the following to match:
    (x{0,9})                       # \1 = conjectured digit; tail -= \1
    # Assert one of the following two alternatives:
    (
        # Assert that \1 occurs as a digit of N, and chop it away (and all the digits
        # right of it) from tail, returning only the digits left of its found instance.
        (
            (?=
                (x*)((\1\4){9}x*)  # \4 = floor((tail + \1) / 10) - \1;
                                   # \5 = tool to make tail = \4
            )
            \5                     # tail = \4
        )*
        (?=
            (x*)(\7{9}$)           # assert tail % 10 == 0; \7 = tail / 10;
                                   # \8 = tool to make tail = \7
        )
        \8\1                       # tail = \7 - \1 (all the digits of N left of where \1
                                   #                 was found, minus \1)
    |
        # Assert that \1 is not a divisor of N
        (?!\1*$)
    )
    # Assert that \1 occurs as a digit in tail+\1, which will either be a second occurrence
    # found further left in N of an already-found occurrence, or any occurrence of a digit
    # that is not a divisor of N.
    (
        (?=
            (x*)((\1\10){9}x*)     # \10 = floor((tail + \1) / 10) - \1;
                                   # \11 = tool to make tail = \10
        )
        \11                        # tail = \10
    )*
    # Assert one of the following two alternatives:
    (
        # Assert tail > 0 and tail % 10 == 0, which means we've found an occurrence of \1
        # that isn't the leftmost digit
        (x{10})+
    |
        # Assert tail == 0 and tail != \1, which means we've found that \1 is the leftmost
        # digit of N and \1 != 0 (which needs to be asserted, otherwise we'd always find
        # a phantom occurrence of the digit 0 left of the leftmost digit of N)
        (?!\1)
    )$
)
x                                  # Prevent N=0 from being matched

```

The version above is very slow, so I'm keeping my **144 byte** solution here:

`^(?!(?=(x*)\1{9})(x{0,9})(?=(x{10})*$|(.*(?=\1$)((?=(x*)(\6{9}x*))\7)*?\B(?=(x*)(\8{9}\2$))\9))((?!\2*$)|\4((?=(x*)(\12{9}x*))\13)*\2(x{10})*$))`

Try it online!

```
^           # tail = N = input number
(?!         # Negative lookahead - Assert that there's no way for the following to match:
    (?=(x*)\1{9})                # \1 = floor(N / 10)
    (x{0,9})                     # \2 = take a guess at a numeral that may occur as any
                                 #      digit of N, even the rightmost one; tail -= \2
    # Assert that \2 occurs as a digit in N, and if it does, identify the rest of N to
    # the left of that digit, so that we can set tail equal to it later (so we can later
    # assert that \2 is not duplicated).
    (?=
        (x{10})*$                # Skip the rest if we picked the rightmost digit of N
    |
        (                        # \4 = tool to make tail = \8
            .*(?=\1$)            # tail = \1
            # Loop through chopping away each rightmost decimal digit of tail, one by one
            (
                (?=
                    (x*)         # \6 = floor(tail / 10)
                    (\6{9}x*)    # \7 = tool to make tail = \6
                )
                \7               # tail = \6
            )*?                  # Only iterate until we find the first match of the
                                 # following:
            \B                   # Leave at least one digit remaining (to avoid
                                 # thinking we've found a zero-digit when there isn't
                                 # actually one)
            (?=(x*)(\8{9}\2$))   # \8 = floor(tail/10); \9 = tool to make tail = \8;
                                 # assert that tail % 10 == \2, i.e. that our guessed
                                 # digit matches the current rightmost digit of tail
            \9                   # tail = \8
        )
    )
    # \2 is now one of the decimal digits of N.
    # Assert that either of the following two alternatives could match, and in the
    # context outside of the negative lookahead, that neither of them can match:
    (
        # Assert tail is not divisible by \2. It doesn't matter that tail == N-\2
        # instead of N, because that doesn't alter tail's divisibility by \2.
        (?!\2*$)
    |                            # or...
        # Assert that \2 doesn't occur as any decimal digit left of where it was found
        \4                       # tail = \8 if \8 is set, otherwise no change; this
                                 #        relies on ECMAScript NPCG behavior.
        # Chop away any number (minimum 0) of rightmost decimal digits of tail
        (
            (?=(x*)(\12{9}x*))   # \12 = floor(tail / 10);
                                 # \13 = tool to make tail = \12
            \13                  # tail = \12
        )*                       # Iterate any number of times, minimum 0
        \2                       # tail -= \2
        (x{10})*$                # assert tail is divisible by 10
    )
)

```

# Regex (ECMAScript + `(?*)`), 81 bytes

`^(?!(?*(((?=(x*)(\3{9}(x*)))\4)+))((?!\5+$)|\1((?=(x*)(\8{9}x*))\9)*\5(x{10})*$))`

This challenge is much easier to solve with molecular lookahead; it's the version I implemented first.

Working on this alerted me to the presence of a bug in my regex engine (now fixed).

```
^           # tail = N = input number
(?!         # Negative lookahead - Assert that there's no way for the following to match:
    (?*     # Molecular lookahead - cycle through all possible matches of the following:
        (                            # \1 = tool to make tail = the final value of \3
            # Loop through chopping away each rightmost decimal digit of tail, one by one
            (
                (?=(x*)(\3{9}(x*)))  # \3 = floor(tail / 10); \4 = tool to make tail = \3;
                                     # \5 =       tail % 10
                \4                   # tail = \3
            )+                       # Iterate at least once, otherwise \5 could be unset
            # The above loop relies on ECMAScript no-empty-optional behavior. This
            # prevents it from matching when the final result of zero is again divided
            # by 10, which would yield a value of \5 = 0, making it look like one of N's
            # digits was zero and preventing all values of N from matching.
        )
    )
    # \5 is now one of the decimal digits of N, and tail==N again
    # Assert that either of the following two alternatives could match, and in the context
    # outside of the negative lookahead, that neither of them can match:
    (
        (?!\5+$)                     # Assert tail is not divisible by \5
    |                                # or...
        # Assert that the \5 doesn't occur as any decimal digit left of where it was found
        \1                           # tail = \3
        # Chop away any number (minimum 0) of rightmost decimal digits of tail
        (
            (?=(x*)(\8{9}x*))        # \8 = floor(tail / 10); \9 = tool to make tail = \8;
            \9                       # tail = \8
        )*                           # Iterate any number of times, minimum 0
        \5                           # tail -= \5
        (x{10})*$                    # assert tail is divisible by 10
    )
)

```

# Regex (ECMAScript 2018), 85 bytes

`^(?!((?=(x*)(\2{9}(x*)))\3)+((?<=(?=(?!\4+$))^.*)|((?=(x*)(\7{9}x*))\8)*\4(x{10})*$))`

Try it online!

This is a port of the molecular lookahead version. The most direct port would be replacing `(?*A)B` with `A(?<=(?=B)^.*)`, but that would result in an 89 byte regex.

```
^           # tail = N = input number
(?!         # Negative lookahead - Assert that there's no way for the following to match:
    # Loop through chopping away each rightmost decimal digit of tail, one by one
    (
        (?=(x*)(\2{9}(x*)))      # \2 = floor(tail / 10); \3 = tool to make tail = \2;
                                 # \4 =       tail % 10
        \3                       # tail = \2
    )+                           # Iterate at least once, otherwise \4 could be unset
    # The above loop relies on ECMAScript no-empty-optional behavior. This prevents it
    # from matching when the final result of zero is again divided by 10, which would
    # yield a value of \4 = 0, making it look like one of N's digits was zero and
    # preventing all values of N from matching.

    # \4 is now one of the decimal digits of N, and tail==\2
    # Assert that either of the following two alternatives could match, and in the context
    # outside of the negative lookahead, that neither of them can match:
    (
        (?<=                     # Variable-length lookbehind - used to go back to start
            (?=
                # now tail==N again
                (?!\4+$)         # Assert tail is not divisible by \4
            )
            ^.*                  # Go back to start, then execute the above lookahead
        )
    |                            # or...
        # now tail==\2
        # Assert that the \4 doesn't occur as any decimal digit left of where it was found
        # Chop away any number (minimum 0) of rightmost decimal digits of tail
        (
            (?=(x*)(\7{9}x*))    # \7 = floor(tail / 10); \8 = tool to make tail = \7;
            \8                   # tail = \7
        )*                       # Iterate any number of times, minimum 0
        \4                       # tail -= \4
        (x{10})*$                # assert tail is divisible by 10
    )
)

```

# Answer
> 4 votes
# Scratch, 249 bytes

Try it online!

I feel as though this could be improved by a few bytes, but I'm not sure...

```
when gf clicked
ask()and wait
set[C v]to()
set[N v]to(answer
repeat(length of(n
change[C v]by(1
add(letter(C)of(N))to[B v
end
say[T
repeat(C
set[D v]to(item(1)of[B v
delete(1)of[B v
if<<[B v]contains(D)?>or<not<((N)/(D))=(round((N)/(D)))>>>then
say(

```

Alternatively, 34 blocks.

# Answer
> 3 votes
# , 17 bytes

```
[:(<.-:~.)10&#.%]

```

Try it online!

Take input as list of digits.

* `10&#.%]` The list of quotients. Returns floats.
* `(<.-:~.)` Does the unique of that list `~.` match `-:` the list formed by rounding every element down to an integer `<.`?

# Answer
> 2 votes
# Japt, ~~15~~ ~~14~~ ~~11~~ ~~10~~ 9 bytes

```
ì®yUÃ¥Uìâ

```

Try it

# Answer
> 2 votes
# Jelly, 8 bytes

```
D⁼QaDḍ$Ạ

```

Try it online!

# Answer
> 2 votes
# PHP, ~~62~~ 48 bytes

```
while($i=$argn[$k++])$r|=$argn%$i|$$i++;echo!$r;

```

Run as pipe with `-nR` or test it online. Empty output for falsy, `1` for truthy.

**breakdown**

```
while($i=$argn[$k++])   # loop through digits
    $r|=                    # set $r to true if
        $argn%$i            # 1. number is not divisible by $i
        |$$i++;             # 2. or digit has been used before
echo!$r;                # print negated $r

```

# Answer
> 2 votes
# Haskell, 61 bytes

```
(#)=<<show
(d:r)#n=notElem d r&&mod n(read[d])<1&&r#n
_#_=0<3

```

Try it online!

Defines an anonymous function `(#)=<<show` which, given a number, returns `True` or `False`.

# Answer
> 2 votes
# ruby -n, 40 bytes

```
p gsub(/./){$'[$&]||$_.to_i%$&.hex}<?0*8

```

Try it online!

Read in the number as a string. Substitute each character (digit) with a subsequent occurrence of that character, if present, or the whole number modulo that digit. This will result in a string of only `0`s if and only if this is a Lynch-Bell number. Why? If there's a repeated digit, every instance of the last stays the same, and since the input doesn't contain zeroes that means a non-zero digit. Otherwise, we're just checking whether every digit evenly divides the number.

Since there are no 8-or-more-digit Lynch-Bell numbers (formal proof: OEIS says so), checking whether the resulting string is lexicographically earlier than the string `'00000000'` is equivalent to checking whether it's all zeroes.

# Answer
> 2 votes
# Excel, ~~76~~ 74 bytes

*-2 bytes using `ROWS` instead of `COUNTA`*

```
=LET(n,LEN(A2),d,MID(A2,SEQUENCE(n),1),AND(ROWS(UNIQUE(d))=n,MOD(A2,d)=0))

```

Spreadsheet

```
LET(                               'Assign Variables
n,LEN(A2)                          '   n = # of digits
d,MID(A2,SEQUENCE(n),1)            '   d = array of digits
AND(ROWS(UNIQUE(d))=n,MOD(A2,d)=0) 'Result
    ROWS(UNIQUE(d))=n              '   # unique d = n
                      MOD(A2,d)=0  '   number mod d = 0
AND(                             ) '   and all tests

```

Original

```
=LET(n,LEN(A2),d,MID(A2,SEQUENCE(n),1),AND(COUNTA(UNIQUE(d))=n,MOD(A2,d)=0))

```

# Answer
> 2 votes
# K (ngn/k), 22 bytes

```
{&/~(t*t~?t:10\x)!\:x}

```

Try it online!

* `(...t:10\x)` get the individual digits of the input, storing in `t`
* `(t*t~?t...)` if the digits aren't all unique, multiply them by 0 (otherwise leave them as-is)
* `(...)!\:x` mod the input by each of the digits (with `x mod 0` == `x`)
* `&/~` are all the remainders 0?

# Answer
> 2 votes
# Vyxal, 57 bitsv2, 7.125 bytes

```
:₌Kf↔$f⁼

```

Try it Online!

Bitstring:

```
010100100010101011101010110011110100011101011011111010110

```

# Answer
> 2 votes
# Uiua, 13 bytes

```
≍⊝⌊.÷-@0$"_".

```

Try it online!

Not too bad, given the bulky syntax to convert a number into its decimal digits. The main idea is taken from alephalpha's Nekomata answer.

Note: the symbol for "match" (test if two arrays are structurally equal as a whole) has been changed from  to .

Also, this code doesn't work when the input contains a 0, because division by 0 gives NaN, floor of NaN is still NaN, and two NaNs are equal.

```
≍⊝⌊.÷-@0$"_".    input: a positive integer
         $"_"     stringify the input
      -@0         subtract '0' from each char, giving decimal digits as numbers
     ÷       .    divide the original number by each digit
≍⊝⌊.             test if this array, floored and deduplicated, still equals itself

```

A version that also handles zero digits (giving falsy) in 15 bytes (Try it):

```
≍⊚=0⊃◿⊛-@0$"_".
          -@0$"_"     decimal digits of input
     ⊃◿⊛       .    push (input % digits, classification of digits)
                      (classify: assign a unique index to each unique element)
 ⊚=0                 indices where input % digits == 0
≍                    match?

```

The final match gives 1 if and only if the number is Lynch-Bell, because:

* `indices where input % digits == 0` has the length equal to the number of digits if and only if `input % digits == 0` is all true,
* its result is precisely `0 1 2 ... x-1` where `x` is the number of digits in that case, and
* the classification is the same if and only if the digits are all unique.

# Answer
> 1 votes
# 05AB1E, 8 bytes

```
SÖP¹DÙQ*

```

Uses the **05AB1E** encoding. Try it online!

# Answer
> 1 votes
# Mathematica, 57 bytes

```
Tr@Boole[IntegerQ/@Union[s=#/IntegerDigits@#]]==Length@s&

```

# Answer
> 1 votes
# Python 2, 66 bytes

This is a solution in Python 2, whose whole purpose is to output `True` for truthy and `False` for falsy:

```
lambda n:len(set(n))==len(n)and not any((int(n)%int(x)for x in n))

```

Try it online!

# Answer
> 1 votes
# Retina, 37 bytes

```
(.).*\1
0
.
<$&$*1>$_$*
<(1+)>\1+

^$

```

Try it online! Link includes test cases. Explanation: The first stage replaces any duplicate digit with a zero. The second stage replaces each digit with its unary representation followed by the unary representation of the original number. The third stage then computes the remainder of the division of original number by each non-zero digit. If the number is a Lynch-Bell number then this will delete everything and this is tested for by the final stage.

# Answer
> 1 votes
## Haskell, ~~260~~ ~~241~~ ~~201~~ 162 bytes

```
f([x])=1<2
f(x:xs)=not(x`elem`xs)&&(f xs)
r n i= n`mod`(read[(show n!!i)]::Int)==0
q n 0=r n 0
q n i=r n i&&q n(i-1)
p n=length(show n)-1
s n=q n(p n)&&f(show n)

```

Explanation

```
f ([x]) = True                                           f function checks for
f (x:xs) = not(x `elem` xs) && (f xs)                    repeated digits
r n i = n `mod` (read [(show n !! i)] :: Int) == 0       checks whether num is
                                                         divisible by i digit
q n 0 = r n 0                                            checks wether n divisible
q n i = r n i && q n (i-1)                               by all of its digits
p n = length (show n) -                                  gets length of number
s n = (q n (p n)) && (f (show n))                        sums it all up!!!

```

Have significantly shortened thanx to Laikoni

# Answer
> 1 votes
## CJam, 17 bytes

CJam is the Java of golfing languages. It's even interpreted in Java!

```
{_Ab__L|=@@f%:+>}

```

### Explanation:

```
{   e# Stack:              3915
_   e# Duplicate:          3915 3915
Ab  e# Digits in base 10:  3915 [3 9 1 5]
__  e# Duplicate twice:    3915 [3 9 1 5] [3 9 1 5] [3 9 1 5]
L|  e# Remove duplicates:  3915 [3 9 1 5] [3 9 1 5] [3 9 1 5]
=   e# Test equality:      3915 [3 9 1 5] 1
@@  e# Rotate twice:       1 3915 [3 9 1 5]
f%  e# Modulo each:        1 [0 0 0 0]
:+  e# Sum:                1 0
>   e# Greater than:       1
}   e# Output:             1 (truthy)

```

# Answer
> 1 votes
## VBScript, 177 bytes

Hey all, this is my very first CG post, and first attempt, so hope I followed all the rules...

```
Function L(s)
dim i,j,k,m,n
j = Len(s)
redim a(j)
n = 0
for i = 0 to j-1
   A(i) = Mid(s,i+1,1)
   m = m + s Mod A(i)
   if j = 1 then
   else
        for k = 0 to i - 1
            if A(i)  = A(k) then n = n + 1
        next
   end if
next
if m + n = 0 then L = "y" else L = "n"
End Function

```

This can be run from Notepad by adding a line at the end

```
Msgbox L(InputBox(""))

```

And then saving it as .vbs, then double click.

Explanation:

```
Function L(s)                  'creates the function "L" taking test number as input
dim i,j,k,t,m,n                'variables
j = Len(s)                     '"j" gets length of test number
redim a(j)                     'creates array "a", size is length of test number
n = 0                          'sets repeat character counter "n" to zero
for i = 0 to j-1               'for length of string
   A(i) = Mid(s,i+1,1)         'each array slot gets one test number character
   m = m + s Mod A(i)          '"m" accumulates moduli as we test divisibility of each digit
   if j = 1 then               'if test number is of length 1, it passes (do nothing)
   else                        'otherwise, gotta test for repeats
        for k = 0 to i - 1     'for each digit already in array, test against current digit
            if A(i)  = A(k) then n = n + 1
                               'repeat char counter "n" stores no of repeats
        next                   'proceed through array looking for repeat
   end if
next                           'test next digit for divisibility and repeats
if m + n = 0 then L = "y" else L = "n"
                               'check for any repeats and moduli,
                               'then return yes or no for LynchBelledness
End Function

```

VBScript is a bit of blunt instrument for golfing, but hey, I haven't learned Ruby yet...

# Answer
> 1 votes
# Pyth, 10 bytes

```
qiRQKjQT{K

```

Verify all the test cases.

## How?

```
qiRQKjQT{K  ~ Full program.

     jQT    ~ The list of decimal digits of the input.
    K       ~ Assign to a variable K.
 iRQ        ~ For each decimal digit...
 i Q          ~ ... Get the greatest common divisor with the input itself.
        {K  ~ K with the duplicate elements removed.
q           ~ Is equal? Output implicitly.

```

# Pyth, 11 bytes

```
&!f%sQsTQ{I

```

Verify all the test cases.

## How?

```
&!f%sQsTQ{I  ~ Full program, with implicit input.

  f     Q    ~ Filter over the input string.
   %sQsT     ~ The input converted to an integer modulo the current digit.
             ~ Keeps it if it is higher than 0, and discards it otherwise.
 !           ~ Negation. If the list is empty, returns True, else False.
&        {I  ~ And is the input invariant under deduplicating? Output implicitly.

```

# Answer
> 1 votes
# Perl 5 `-p`, ~~34~~ 29 bytes

```
$_=!grep$k{$_}++|"@F"%$_,/./g

```

Try it online!

# Answer
> 1 votes
# APL (Dyalog Unicode), 24 bytes

```
{((,⍵)≡∪⍵)×∧/0=(⍎¨⍵)|⍎⍵}

```

Try it online!

Simple Dfn, can probably be golfed a bit more. Yield standard APL booleans 1 for truthy, 0 for falsy.

It's worth to mention that the function takes the arguments as strings rather than ints.

### How:

```
{((,⍵)≡∪⍵)×∧/0=(⍎¨⍵)|⍎⍵} ⍝ Dfn, argument ⍵.
                      ⍎⍵  ⍝ Convert ⍵ to integer
                     |    ⍝ Modulus
                (⍎¨⍵)     ⍝ Each digit in ⍵
              0=          ⍝ Equals 0? Returns a vector of booleans
            ∧/            ⍝ Logical AND reduction
           ×              ⍝ multiplied by (the result of)
  (     ∪⍵)               ⍝ unique elements of ⍵
       ≡                  ⍝ Match
   (,⍵)                   ⍝ ⍵ as a vector; the Match function then returns 1 iff all digits in ⍵ are unique

```

# Answer
> 1 votes
# , 86 bytes

```
x=scan(,'');a=as.double;all(table(utf8ToInt(x))==1)&&all(!a(x)%%a(el(strsplit(x,""))))

```

Takes input as a string. I certainly feel like this is golfable.

Try it online!

# , 62 bytes

Golf by Giuseppe

```
all(table(d<-utf8ToInt(x<-scan(,''))-48)<2)&all(!strtoi(x)%%d)

```

Try it online!

# Answer
> 1 votes
# Python 3, 50 bytes

```
lambda n:all(int(n)%int(d)+n.count(d)<2for d in n)

```

Try it online!

Returns `True` if the (zero-free) number is a Lynch-Bell number, `False` otherwise.

# Answer
> 1 votes
# Nekomata \+ `-e`, 3 bytes

```
Ɗ¦ů

```

Attempt This Online!

```
Ɗ¦ů
Ɗ       Decimal digits
 ¦      Divided by, and check if the result are integers
  ů     Check if all elements are unique

```

# Answer
> 0 votes
# Neim, 9 bytes

```
ℚ₁₁₁ℚ

```

Try it online!

-2 thanks to Okx.

Hmm, there's a nice symmetry... `oO.O.O.Oo`

# Answer
> 0 votes
# PHP, 51 bytes

prints zero for true and one for false

```
for(;$c=$argn[$i++];$$c=1)$t|=$$c||$argn%$c;echo$t;

```

Try it online!

# PHP, 62 bytes

prints zero for true and one for false

```
for($a=$argn;$c=$a[$i];)$t|=strpos($a,$c)<+$i++||$a%$c;echo$t;

```

Try it online!

# Answer
> 0 votes
# Perl 6, 27 bytes

```
{$_%%.comb.all&&[!=] .comb}

```

Try it online!

* `.comb` is a method which, when given no arguments, splits a string into its individual characters. A number is implicitly converted into a string, and so `.comb` returns its digits.
* `.comb.all` is an and-junction of all of the digits.
* `$_ %% .comb.all` is an and-junction of the divisibility of the input argument `$_` by all of its digits. For example, if `$_` is `123`, the junction is `all(True, False, True)`, which collapses to `False` in a truthy context.
* `[!=] .comb` reduces the digits of the input argument with the `!=` operator, which evaluates to `True` if the digits are all different.

# Answer
> 0 votes
# Ruby 2.4, 42 bytes

```
->x{(r=x.digits)|[]==r&&r.none?{|f|x%f>0}}

```

(No TIO yet, sorry)

# Answer
> 0 votes
# Kotlin 1.1, ~~98~~ ~~66~~ 59 bytes

```
{i->i.none{i.toInt()%(it-'0')>0}&&i.length==i.toSet().size}

```

## Beautified

```
{i ->
    // None of the digits are not factors
    i.none { i.toInt() % (it-'0') > 0 }
    // AND
    &&
    // None of the digits are repeated
    i.length == i.toSet().size
}

```

## Test

```
var L:(String)-> Boolean =
{i->i.none{i.toInt()%(it-'0')>0}&&i.length==i.toSet().size}
data class TestData(val input: String, val output: Boolean)

fun main(args: Array<String>) {
    var inputs = listOf(
        TestData("7", true),
        TestData("126", true),
        TestData("54", false),
        TestData("55", false),
        TestData("3915", true)
    )

    for (test in inputs) {
        if (L(test.input) != test.output) {
            throw AssertionError(test.toString())
        }
    }
    println("Test Passed")
}

```

# Answer
> 0 votes
# Julia 1.0, 39 bytes

```
f(x,d=digits(x))=rem.(x,d)==0*unique(d)

```

`rem.(x,d)` is a vector containing the remainders after dividing x by each digit in `x`. `0*unique(d)` is a vector with length equal to the number of unique digits, with all zero values. Check if they are equal.

Try it online!

# Answer
> 0 votes
# PowerShell, 95 bytes

```
param($n)$a="$n"|% t*y;if($n-eq([int](($a|gu)-join''))){
($a|%{12%[int]"$_"})-contains0}else{0}

```

Try it online!

# Answer
> 0 votes
# APL (Dyalog Unicode), 31 bytes

```
{∧/(0=⍺|⍨¨⍵)∧(⊢≡∪)⍵}∘(10⊥⍣¯1⊢)⍨
 ∧/ ⍝ reduction by logical AND
   0=⍺|⍨¨⍵ ⍝ divisibility check
     ∧ ⍝ logical AND
       (⊢≡∪)⍵ ⍝ check for unique digits
         ∘ ⍝ function composition operator (Beside)
           10⊥⍣¯1⊢ ⍝ convert to array of digits
             ⍨ ⍝ commute operator (Selfie), used to copy input to left side of the composed function

```

Try it online!

# Answer
> 0 votes
# Python 3, ~~88~~ 86 bytes

```
def f(n):
 s=""
 for i in n:
  if i in s or int(n)%int(i)!=0:return 0
  s+=i
 return 1

```

Fixed that it wasn't running with whitespace removed - thanks to @caird coinheringaahing

# Answer
> 0 votes
# Desmos, 109 bytes

```
n=q-48
l=n.length
abs(\prod_{a=1}^l\prod_{b=a+1}^{l}(n[b]-n[a])(1-sign(mod(\sum_{c=1}^ln[c]10^{l-c},n).max)))

```

View it in Desmos

There's got to be a better way to do this, but I can't come up with it right now. This is sort of split up into a few sections:

```
n=q-48

```

This turns codepoints into digits for convenience's sake

```
\prod_{a=1}^l\prod_{b=a+1}^{l}(n[b]-n[a])

```

This checks if any two digits are equal, and if so, returns 0

```
\sum_{c=1}^ln[c]10^{l-c}

```

This turns the list of digits into the number

```
1-sign(mod(\sum_{c=1}^ln[c]10^{l-c},n).max)

```

This uses the previous section to check if any digit isn't divisible by the sum, and if so, returns 0

Then we turn this into a 1 if the result succeeds both tests and 0 if it fails one. We can cut out 5 bytes if we accept any non-zero number as true by removing the `abs(` from the start of the third equation and `)` from the end, but I'm not sure if negative numbers really count as truthy. We can also get rid of 6 bytes if we can accept a list of digits as input rather than a string.

# Answer
> 0 votes
# JavaScript (Node.js), 33 bytes

```
s=>[...s].every(y=e=>y[e]^=s%e<1)

```

Try it online!

If an `e` appears twice then `s%e<1` is still true, and `y[e]^=` returns 0

---
Tags: code-golf, number, decision-problem
---


title: Generate Monday Numbers

text:
# Question
Title: Generate Monday Numbers
**Monday numbers**, as defined by Gamow in this question over on Puzzling, are positive integers *N* with the following three properties:

* The decimal representation of *N* does not contain the digit 0
* The decimal representation of *N* does not contain any digit twice
* *N* is divisible by every digit *D* that occurs in its decimal representation

Note that these are alternatively known, in the OEIS, as Lynch-Bell numbers.

### Examples:

* `15` is a Monday number, as it's divisible by both `1` and `5` and satisfies the other two conditions
* `16` is not, because it's not divisible by `6`.
* The number `22` is not, because though it satisfies conditions 1 and 3, it fails condition 2.

Here's the list of the first 25 Monday numbers to get you started (there are 548 total):

> 1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248

The challenge here is to **write the shortest code that generates the full sequence of Monday numbers,** from 1 up to 9867312 (proven on that question to be the largest possible).

Your code should take no input, and output should be to STDOUT or equivalent, with your choice of delimiter. All the usual code-golf rules apply, and Standard Loopholes are prohibited.

## Leaderboard

```
var QUESTION_ID=59014,OVERRIDE_USER=42963;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
# Jelly, 8 bytes

```
ȷ7Dg⁼QƲƇ

```

Runs locally in under eight minutes.

Try it online! (modified to find numbers with six digits or less)

### How it works

```
ȷ7Dg⁼QƲƇ  Main link. No arguments.

ȷ7        Set the return value to 10**7.
       Ƈ  Comb; promote 10**7 to [1, ..., 10**7], then keep only those n in the range
          for which the link to the left returns a truthy value.
      Ʋ     Combine the four links to the left into a monadic chain.
  D           Decimal; yield n's digit array in base 10.
   g          Take the GCD of each digit and n.
     Q        Yield the unique digits of n.
    ⁼         Test both results for equality.

```
> 3 votes

# Answer
## Python 2, 85 bytes

```
print[n for n in range(1,9**9)if(n<10**len(set(`n`)))>any(n%(int(d)or.3)for d in`n`)]

```

Prints a list.

I'm basically combining two of my answers to previous challenges:

Thanks to xsot for 1 byte saved by combining the conditions better.
> 16 votes

# Answer
# Perl, ~~61~~ 47 bytes

46 bytes code + 1 byte command line parameter.

```
/(.).*\1|0/||1*s/./$_%$&/rge||print for 1..1e7

```

### Usage:

```
perl -l entry.pl

```

### Explanation

`/(.).*\1|0/` returns 1 if the number-under-test contains a duplicate character or a 0

`s/./$_%$&/rge` replaces each digit with the value of the number-under-test % the digit. For example, 15 -\> 00, 16 -\> 04 (because 16%6=4). This means that any input which is divisible by all of its digits will consist of all 0s, otherwise it will contain a digit \>0. In order to treat this as a number, we \*1, which means any number-under-test will return 0 for this block if it is divisible by all of its digits, otherwise \>0.

By separating these two statements and the print with 'or's, if either of the first two conditions returns \>0, the condition matches and the subsequent parts of the expression will not evaluate. If and only if both previous conditions are 0, the print will then execute. The `-l` flag ensures to add a new line after each print.
> 11 votes

# Answer
# Pyth, ~~22~~ 21

```
f&.{`T!f%T|vY.3`TS^T7

```

Thanks to Jakube for golfing off 1 byte of unnecessary formatting.

Heavily inspired by this CW answer to the related question.

I have a paste of the result here, from when it printed newline separated, now it prints as a pythonic list.

I would recommend not trying it online unless you use a number smaller than 7... I've set it to 2 in this link.

Filters from `1` to `10^7-1` which covers all the necessary values. This version may cause a memory error if it cannot make the list `S^T7`, which is similar to `list(range(1,10**7))` in python 3 (However, it works fine for me). If so, you could try:

```
.f&.{`Z.x!s%LZjZT0548

```

Which finds the first 548 Monday numbers. This also demonstrates another way to check for the `0`s in the number, instead of replacing them with `.3` this uses a try-catch block. Credit for this version goes entirely to Jakube. (Note that this is still much to slow for the online interpreter)
> 10 votes

# Answer
## GS2, 20 19 bytes

gs2 uses a wide range of bytes, not just printable ascii chracters. I will present my solution in hex.

```
17 7d 2f 24 65 f1 c8 24 d8 62 e9 65 f4 24 40 90 71 f3 54

```

Here's some explanation. gs2 is a stack based language, so there are no variables. (aside from 4 registers, one of which i use here)

```
17         # push constant 7
7d         # 10 raised to the power
2f         # create an array of numbers from 1 to n

    24     # get digits of number into array
    65     # calculate product of array
f1         # filter array by previous block of 2 instructions

    c8     # save top of stack to register a
    24     # get digits of number into array
        d8 # tuck register a under top of stack
        62 # boolean divisibility test
    e9     # map array using previous block of 2 instructions
    65     # calculate product of array
f4         # filter array by previous block of 5 instructions

    24     # get digits of number into array
    40     # duplicate top of stack
    90     # remove duplicates from array
    71     # test equality
f3         # filter array by previous block of 4 instructions
54         # show contents of array separated by line breaks

```
> 9 votes

# Answer
# Python 3, ~~132~~ ~~128~~ ~~114~~ ~~111~~ 104 bytes

```
i=0
while i<1e8:
 j=str(i)
 if len(set(j))+2==len(j)+('0'in j)+all(i%int(k)<1 for k in j):print(i)
 i+=1

```

There are 548 Monday Numbers.
> 8 votes

# Answer
# APL, ~~44~~ ~~39~~ 37 bytes

```
{0=+/(⊢|∘⍵,0∘∊,⍴∘⊢≠⍴∘∪)⍎¨⍕⍵:⍵⋄⍬}¨⍳1e7

```

Ungolfed:

```
{
 x ← ⍎¨⍕⍵⋄                    ⍝ Define x to be a vector of the digits of ⍵
 0=+/(⊢|∘⍵,0∘∊,⍴∘⊢≠⍴∘∪)x:   ⍝ No zeros, all digits divide ⍵, all unique?
 ⍵⋄⍬                          ⍝ If so, return the input, otherwise null
}¨⍳1e7                        ⍝ Apply to the integers 1..1E7

```

Saved 7 bytes thanks to Moris Zucca!
> 7 votes

# Answer
# TI-BASIC, ~~60~~ 59 bytes

```
For(X,1,ᴇ7
int(10fPart(X10^(-randIntNoRep(1,1+int(log(X->D
SortA(∟D
If X>9
If not(max(remainder(X,Ans+2Xnot(Ansmin(ΔList(∟D
Disp X
End

```

`∟D` is the list of digits, which is generated using math and the `randIntNoRep(` command (random permutation of all integers between `1` and `1+int(log(X` inclusive). I use a slightly complicated chain of statements to check if all of the conditions are satisfied:

```
   min(ΔList(∟D        ;Zero if repeated digit, since ∟D was sorted ascending
Ans                    ;Multiplies the unsorted copy of ∟D by the minimum from above
                       ;(Lists are different dimensions; we can't elementwise AND)
                       ;Will contain a 0 if there's a 0 digit or a repeated digit
      not(             ;If there's a zero,
Ans+2X                 ;Add 2X to that pos. in the list, failing the test:

    max(remainder(X,   ;Zero iff all digits divide X and 2X wasn't added
not(

```

To fail numbers that have repeated digits or zero digits, I replace zeroes with `2X`, because `X` is never divisible by `2X`.

To special-case 1~9 (because `ΔList(` on a one-element list errors) I use the `If` statement in the fourth line to skip over the check in the fifth line, automatically displaying all `X`≤9.

The output numbers are separated by newlines.
> 6 votes

# Answer
# Mathematica 105

```
l=Length;Cases[Range@9867312,n_ /;(FreeQ[i=IntegerDigits@n,0]&&l@i== l@Union@i&&And@@(Divisible[n,#]&/@i))]

```
* `IntegerDigits` breaks up `n` into a list of its digits, `i`.
* `FreeQ[i,0]` checks whether there are no zeros in the list.
* `Length[i]==Length[Union[i]]` checks that there are no repeated digits.
* `And@@(Divisible[n,#]&/@i)` checks that each digit is a divisor of `n`.

> {1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 24, 36, 48, 124, 126, 128, 132, 135, 162, 168, 175, 184, 216, 248, 264, 312, 315, 324, 384, 396, 412, 432, 612, 624, 648, 672, 728, 735, 784, 816, 824, 864, 936, 1236, 1248, 1296, 1326, 1362, 1368, 1395, 1632, 1692, 1764, 1824, 1926, 1935, 1962, 2136, 2184, 2196, 2316, 2364, 2436, 2916, 3126, 3162, 3168, 3195, 3216, 3264, 3276, 3492, 3612, 3624, 3648, 3816, 3864, 3915, 3924, 4128, 4172, 4236, 4368, 4392, 4632, 4872, 4896, 4932, 4968, 6132, 6192, 6312, 6324, 6384, 6432, 6912, 6984, 8136, 8496, 8736, 9126, 9135, 9162, 9216, 9315, 9324, 9432, 9612, 9648, 9864, 12384, 12648, 12768, 12864, 13248, 13824, 13896, 13968, 14328, 14728, 14832, 16248, 16824, 17248, 18264, 18432, 18624, 18936, 19368, 21384, 21648, 21784, 21864, 23184, 24168, 24816, 26184, 27384, 28416, 29736, 31248, 31824, 31896, 31968, 32184, 34128, 36792, 37128, 37296, 37926, 38472, 39168, 39816, 41328, 41832, 42168, 42816, 43128, 43176, 46128, 46872, 48216, 48312, 61248, 61824, 62184, 64128, 68712, 72184, 73164, 73248, 73416, 73962, 78624, 79128, 79632, 81264, 81432, 81624, 81936, 82416, 84216, 84312, 84672, 87192, 89136, 89712, 91368, 91476, 91728, 92736, 93168, 93816, 98136, 123648, 123864, 123984, 124368, 126384, 129384, 132648, 132864, 132984, 134928, 136248, 136824, 138264, 138624, 139248, 139824, 142368, 143928, 146328, 146832, 148392, 148632, 149328, 149832, 162384, 163248, 163824, 164328, 164832, 167328, 167832, 168432, 172368, 183264, 183624, 184392, 184632, 186432, 189432, 192384, 193248, 193824, 194328, 194832, 198432, 213648, 213864, 213984, 214368, 216384, 218736, 219384, 231648, 231864, 231984, 234168, 234816, 236184, 238416, 239184, 241368, 243168, 243768, 243816, 247968, 248136, 248976, 261384, 263184, 273168, 281736, 283416, 284136, 291384, 293184, 297864, 312648, 312864, 312984, 314928, 316248, 316824, 318264, 318624, 319248, 319824, 321648, 321864, 321984, 324168, 324816, 326184, 328416, 329184, 341928, 342168, 342816, 346128, 348192, 348216, 348912, 349128, 361248, 361824, 361872, 362184, 364128, 364728, 367248, 376824, 381264, 381624, 382416, 384192, 384216, 384912, 391248, 391824, 392184, 394128, 412368, 413928, 416328, 416832, 418392, 418632, 419328, 419832, 421368, 423168, 423816, 427896, 428136, 428736, 431928, 432168, 432768, 432816, 436128, 438192, 438216, 438912, 439128, 461328, 461832, 463128, 468312, 469728, 478296, 478632, 481392, 481632, 482136, 483192, 483216, 483672, 483912, 486312, 489312, 491328, 491832, 493128, 498312, 612384, 613248, 613824, 613872, 614328, 614832, 618432, 621384, 623184, 623784, 627984, 631248, 631824, 632184, 634128, 634872, 641328, 641832, 643128, 648312, 671328, 671832, 681432, 684312, 689472, 732648, 732816, 742896, 746928, 762384, 768432, 783216, 789264, 796824, 813264, 813624, 814392, 814632, 816432, 819432, 823416, 824136, 824376, 831264, 831624, 832416, 834192, 834216, 834912, 836472, 841392, 841632, 842136, 843192, 843216, 843912, 846312, 849312, 861432, 864312, 873264, 891432, 894312, 897624, 912384, 913248, 913824, 914328, 914832, 918432, 921384, 923184, 927864, 931248, 931824, 932184, 934128, 941328, 941832, 943128, 948312, 976248, 978264, 981432, 984312, 1289736, 1293768, 1369872, 1372896, 1376928, 1382976, 1679328, 1679832, 1687392, 1738296, 1823976, 1863792, 1876392, 1923768, 1936872, 1982736, 2137968, 2138976, 2189376, 2317896, 2789136, 2793168, 2819376, 2831976, 2931768, 2937816, 2978136, 2983176, 3186792, 3187296, 3196872, 3271968, 3297168, 3298176, 3619728, 3678192, 3712968, 3768912, 3796128, 3816792, 3817296, 3867192, 3869712, 3927168, 3928176, 6139728, 6379128, 6387192, 6389712, 6391728, 6719328, 6719832, 6731928, 6893712, 6913872, 6971328, 6971832, 7168392, 7198632, 7231896, 7291368, 7329168, 7361928, 7392168, 7398216, 7613928, 7639128, 7829136, 7836192, 7839216, 7861392, 7863912, 7891632, 7892136, 7916328, 7916832, 7921368, 8123976, 8163792, 8176392, 8219736, 8312976, 8367912, 8617392, 8731296, 8796312, 8912736, 8973216, 9163728, 9176328, 9176832, 9182376, 9231768, 9237816, 9278136, 9283176, 9617328, 9617832, 9678312, 9718632, 9723168, 9781632, 9782136, 9812376, 9867312}

```
Length[%]

```

> 548
> 5 votes

# Answer
# Haskell, 77 bytes

```
[x|x<-[1..9^9],all(\a->a>'0'&&mod x(read[a])+sum[1|y<-show x,y==a]<2)$show x]

```

Usage example (the first 20 numbers):

```
take 20 $ [x|x<-[1..9^9],all(\a->a>'0'&&mod x(read[a])+sum[1|y<-show x,y==a]<2)$show x]

[1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162]

```

How it works: iterate over all numbers from 1 to 9^9 and check the conditions. The current number `x` is turned into it's string representation (`show x`) to operate on it as a list of characters.
> 5 votes

# Answer
# R, 99 bytes

```
for(n in 1:1e8){i=1:nchar(n);if(all(table(d<-(n%%10^i)%/%10^(i-1))<2)&!0%in%d&all(!n%%d))cat(n,"")}

```

Slightly less golfed:

```
for(n in 1:1e8){
    i = 1:nchar(n)
    d = (n%%10^i)%/%10^(i-1) # Digits of n
    if(all(table(d)<2) # No digits is present more than once
      & !0%in%d        # 0 is not one of the digits
      & all(!n%%d))    # All digits are divisors of n
    cat(n,"")
    }

```
> 5 votes

# Answer
## Perl, 90 75 70 bytes

```
print+($_,$/)x(grep(!/(\d).*\1|0/,$_)&s/./!$&||$_%$&/ger<1)for 1..1e7

```
> 5 votes

# Answer
# 05AB1E, ~~30~~ ~~22~~ ~~21~~ ~~18~~ ~~14~~ ~~13~~ ~~12~~ 9 bytes

-9 byte thanks to the help and encouragement of *@Emigna* and *@Mr.Xcoder*. Thanks for letting me mostly figure it out myself, even though you already had a 12-byte solution in mind when I was still at 30. Learned a lot about 05AB1E from this challenge!
-3 bytes thanks to *@Grimy*

```
7°LʒÐÑÃÙQ

```

Try it online (only outputs the numbers below 103 instead of 107 to prevent a timeout after 60 sec).

**Explanation:**

```
7°L        # Generate a list in the range [1, 10^7]
   ʒ       # Filter, so only the numbers that evaluated to 1 (truthy) remain:
    Ð      #  Triplicate the current number
     Ñ     #  Get the divisors of this number
           #   i.e. 128 → [1,2,4,8,16,32,64,128]
           #   i.e. 1210 → [1,2,5,10,11,22,55,110,121,242,605,1210]
      Ã    #  Only keep those digits/numbers in the original number (which is checked in
           #  order, so it will only keep the digits and ignores the later numbers)
           #   i.e. 128 → 128
           #   i.e. 1210 → 121
       Ù   #  Uniquify the number, removing any duplicated digits
           #   i.e. 128 → 128
           #   i.e. 121 → 12
        Q  #  Check if the number is unchanged after this
           #   i.e. 128 and 128 → 1 (truthy)
           #   i.e. 1210 and 12 → 0 (falsey)

```

---

**Previous 12 byter version (one of my very first 05AB1E answers):**
NOTE: Only works in the legacy version of 05AB1E.

```
7°LʒÐSÖPsDÙQ*

```

Try it online (only outputs the numbers below 103 instead of 107 to prevent a timeout after 60 sec).

**Explanation:**

```
7°L        # Generate a list in the range [1, 10^7]
   ʒ       # Filter, so only the numbers that evaluated to 1 (true) remain:
    Ð      #  Triplicate the current number N
     Ù     #  Remove all duplicated digits of the second N
           #   i.e. 1210 → 120
      Q    #  Check if the last two numbers are still the same (1 or 0 as result)
    *      #  Multiply this result with remaining third number from the triplication
     D     #  Duplicate this number, so we have two again
      S    #  Separate all the digits of the second one
           #   i.e. 128 → ['1', '2', '8']
       Ö   #  Check if (the second) N is divisible by each of its digits
           #   i.e. 128 and ['1', '2', '8'] → [1, 1, 1]
           #   (NOTE: If the number contains a '0', it won't error on division by 0,
           #          but instead return the number N itself in the list)
           #   i.e. 105 and ['1', '0', '5'] → [1, 105, 1]
        P  #  Take the product of this list (if the divisible test for one
           #  of the digits was 0, this will be 0 as well)
           #   i.e. [1, 1, 1] → 1
           #   i.e. [1, 105, 1] → 105 (only 1 is truthy in 05AB1E)

```
> 5 votes

# Answer
# CJam, 25 bytes

```
1e7{_Ab__&0-_@=@@f%1b>},`

```

Try it online. Note that online link only runs to 10,000. I'm not sure if it would finish online if you're patient enough. It haven't tested it with the offline version of CJam, but I expect that it would terminate.

Explanation:

```
1e7     Upper limit.
{       Start filter loop.
  _Ab     Copy and convert to list of decimal digits.
  __&     Intersect list with itself to remove duplicates.
  0-      Remove zero.
  _       Make a copy of unique non-zero digits. Will use these as divisors.
  @=      Compare unique non-zero digits to all digits. Must be true for Monday numbers.
  @@      Rotate original number and list of non-zero digits to top.
  f%      Remainders of original number with all non-zero digits.
  1b      Sum up the remainders. Since they all must be zero for Monday numbers,
          their sum must be zero.
  >       Check that first part of condition was 1, and sum of remainders 0.
},      End filter loop.
`       Convert resulting list to string.

```
> 4 votes

# Answer
## C#, ~~230~~ 227

It's been a while since I've golved so I probably forgot a few tricks to get the bytecount down. Will improve when I think of them... For now:

```
using System.Linq;class P{static void Main(){System.Console.Write(string.Join(",",Enumerable.Range(0,1<<24).Where(i=>{var s=i.ToString();return!s.Contains('0')&&s.Length==s.Distinct().Count()&&s.All(x=>i%(48-(int)x)==0);})));}}

```

Ungolfed:

```
using System.Linq;
class P
{
    static void Main()
    {
        System.Console.Write(                                       //Output...
            string.Join(                                            //...all results...
                ",",                                                //...comma separated...
                Enumerable.Range(0, 1<<24)                          //...from 0 to 16777216...
                    .Where(i => {                                   //...where...
                        var s = i.ToString();                       //...the digits as char array (what we usually call a string)...
                        return !s.Contains('0')                     //...for which none of the digits is 0...
                            && s.Length == s.Distinct().Count()     //...and the number of distinct digits equals the total number of digits (e.g. all unique)...
                            && s.All(x => i % (48 - (int)x) == 0);  //...and the number is divisible by each of the digits (after 'ASCII-correction')
                    })
            )
        );
    }
}

```

> 1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162,168,175,184,216,248,264,312,315,324,384,396,412,432,612,624,648,672,728,735,784,816,824,864,936,1236,1248,1296,1326,1362,1368,1395,1632,1692,1764,1824,1926,1935,1962,2136,2184,2196,2316,2364,2436,2916,3126,3162,3168,3195,3216,3264,3276,3492,3612,3624,3648,3816,3864,3915,3924,4128,4172,4236,4368,4392,4632,4872,4896,4932,4968,6132,6192,6312,6324,6384,6432,6912,6984,8136,8496,8736,9126,9135,9162,9216,9315,9324,9432,9612,9648,9864,12384,12648,12768,12864,13248,13824,13896,13968,14328,14728,14832,16248,16824,17248,18264,18432,18624,18936,19368,21384,21648,21784,21864,23184,24168,24816,26184,27384,28416,29736,31248,31824,31896,31968,32184,34128,36792,37128,37296,37926,38472,39168,39816,41328,41832,42168,42816,43128,43176,46128,46872,48216,48312,61248,61824,62184,64128,68712,72184,73164,73248,73416,73962,78624,79128,79632,81264,81432,81624,81936,82416,84216,84312,84672,87192,89136,89712,91368,91476,91728,92736,93168,93816,98136,123648,123864,123984,124368,126384,129384,132648,132864,132984,134928,136248,136824,138264,138624,139248,139824,142368,143928,146328,146832,148392,148632,149328,149832,162384,163248,163824,164328,164832,167328,167832,168432,172368,183264,183624,184392,184632,186432,189432,192384,193248,193824,194328,194832,198432,213648,213864,213984,214368,216384,218736,219384,231648,231864,231984,234168,234816,236184,238416,239184,241368,243168,243768,243816,247968,248136,248976,261384,263184,273168,281736,283416,284136,291384,293184,297864,312648,312864,312984,314928,316248,316824,318264,318624,319248,319824,321648,321864,321984,324168,324816,326184,328416,329184,341928,342168,342816,346128,348192,348216,348912,349128,361248,361824,361872,362184,364128,364728,367248,376824,381264,381624,382416,384192,384216,384912,391248,391824,392184,394128,412368,413928,416328,416832,418392,418632,419328,419832,421368,423168,423816,427896,428136,428736,431928,432168,432768,432816,436128,438192,438216,438912,439128,461328,461832,463128,468312,469728,478296,478632,481392,481632,482136,483192,483216,483672,483912,486312,489312,491328,491832,493128,498312,612384,613248,613824,613872,614328,614832,618432,621384,623184,623784,627984,631248,631824,632184,634128,634872,641328,641832,643128,648312,671328,671832,681432,684312,689472,732648,732816,742896,746928,762384,768432,783216,789264,796824,813264,813624,814392,814632,816432,819432,823416,824136,824376,831264,831624,832416,834192,834216,834912,836472,841392,841632,842136,843192,843216,843912,846312,849312,861432,864312,873264,891432,894312,897624,912384,913248,913824,914328,914832,918432,921384,923184,927864,931248,931824,932184,934128,941328,941832,943128,948312,976248,978264,981432,984312,1289736,1293768,1369872,1372896,1376928,1382976,1679328,1679832,1687392,1738296,1823976,1863792,1876392,1923768,1936872,1982736,2137968,2138976,2189376,2317896,2789136,2793168,2819376,2831976,2931768,2937816,2978136,2983176,3186792,3187296,3196872,3271968,3297168,3298176,3619728,3678192,3712968,3768912,3796128,3816792,3817296,3867192,3869712,3927168,3928176,6139728,6379128,6387192,6389712,6391728,6719328,6719832,6731928,6893712,6913872,6971328,6971832,7168392,7198632,7231896,7291368,7329168,7361928,7392168,7398216,7613928,7639128,7829136,7836192,7839216,7861392,7863912,7891632,7892136,7916328,7916832,7921368,8123976,8163792,8176392,8219736,8312976,8367912,8617392,8731296,8796312,8912736,8973216,9163728,9176328,9176832,9182376,9231768,9237816,9278136,9283176,9617328,9617832,9678312,9718632,9723168,9781632,9782136,9812376,9867312
> 4 votes

# Answer
# TI-BASIC, ~~55~~ 53 bytes

This is a relatively minor edit of Thomas Kwa's answer, but I am submitting it as a new answer because I'd heard that he has put a bounty on golfing his TI-BASIC answers.

```
For(X,1,ᴇ7
int(10fPart(X10^(-randIntNoRep(0,1+int(log(X->D
SortA(∟D
If not(sum(remainder(X,Ans+Xnot(Ansmin(ΔList(∟D
Disp X
End

```

My main change is from `randIntNoRep(1,` to `randIntNoRep(0,` meaning that there will now a zero in every generated list of digits.

```
number  |  randIntNoRep  |  digits  |  sorted
9       |  1,0           |  9,0     |  0,9
102     |  3,1,0,2       |  1,2,0,0 |  0,0,1,2

```

Since there's now a zero in every set of digits, this affects the sum of the remainders. Normally the sum of the remainders is 0, but now, the presence of an extra zero causes one failure of our divisibility test.
To counteract this, I changed `2Xnot(` to `Xnot(`. The 2 was originally there to make the test fail at 0, but now it passes at zero. Numbers that contain a zero in their digits, however, now have a `min(ΔList(∟D` of zero anyways (since there's 2 or more zeros in their lists) so this change does not cause any extra numbers to pass the test.

The benefit of this method is that, since there are now "two digits" produced from the number 1-9, the `ΔList(` function does not produce an error, allowing us to get rid of a special condition for single-digit numbers.
> 4 votes

# Answer
# Perl, 97 bytes

```
print+($n=$_,$/)x(!/0/&(y///c==grep{2>eval"$n=~y/$_//"}/./g)&&y///c==grep!($n%$_),/./g)for 1..1e7

```

Takes a while to run, but produces the required output, change to `1e3` for a quicker example!
> 3 votes

# Answer
# Julia, 88 bytes

```
print(join(filter(i->(d=digits(i);0∉d&&d==unique(d)&&all(j->i%j<1,d)),1:9867312)," "))

```

This simply takes all numbers from 1 up to the largest Lynch-Bell number and filters them down to only the Lynch-Bell numbers.

Ungolfed:

```
lynch = filter(i -> (d = digits(i);
                     0 ∉ d &&
                     d == unique(d) &&
                     all(j -> i % j == 0, d)),
               1:9867312)

print(join(lynch, " "))

```
> 3 votes

# Answer
# Python 2, 101 bytes

```
print[i for i in range(6**9)if'0'not in`i`and len(set(`i`))==len(`i`)and all(i%int(k)==0for k in`i`)]

```

You can omit the `print` in the interpreter get to 96. Used `6**9` since it is 8 digits while the largest monday number is only 7 digits, something like `9**9` would probably take a long time, 6\**9 only takes about 10 seconds.
> 3 votes

# Answer
# MATLAB, 100

```
o=49;for n=2:1e7 a=num2str(n);if all([diff(sort(a)) a~=48 ~mod(n,a-48)]) o=[o ',' a];end;end;disp(o)

```

And in a more readable format:

```
o=49;  %1 is always in there, so add the ASCII value. This prevents there being a ',' prefixed.
for n=2:1e7
    a=num2str(n);
    if (all([diff(sort(a)) a~=48 ~mod(n,a-48)]))
        o=[o ',' a];
    end
end
disp(o)

```

Basically this counts through every number between \\$1\\$ and \\$1\times10^7\\$ and checks if they are a Monday number. Each number is converted to a string so that the digits can be dealt with individually.

The checks are as follows:

1. First check if there are any duplicates. By sorting the array, if the difference between any consecutive digits is zero, then there are duplicates

```
diff(sort(a))

```
2. Check if there are any zeros. The ASCII for 0 is 48, so we check that all digits are not equal to that.

```
a~=48

```
3. Check if it is divisible by all its digits. We check that the remainder when dividing by each digit (converted from ASCII to decimal, hence -48) is zero.

```
~mod(n,a-48)

```

Finally we make sure that `all()` the checks are true, and if so we append it to a comma separated output string.

MATLAB has no STDOUT, so instead I print the result string at the end using `disp()`

---

This code is SLOW! I am still running it to make sure that it correctly finds all the Monday numbers, but looks good so far.

Update:

Code finished running. It prints the following:

```
1,2,3,4,5,6,7,8,9,12,15,24,36,48,124,126,128,132,135,162,168,175,184,216,248,264,312,315,324,384,396,412,432,612,624,648,672,728,735,784,816,824,864,936,1236,1248,1296,1326,1362,1368,1395,1632,1692,1764,1824,1926,1935,1962,2136,2184,2196,2316,2364,2436,2916,3126,3162,3168,3195,3216,3264,3276,3492,3612,3624,3648,3816,3864,3915,3924,4128,4172,4236,4368,4392,4632,4872,4896,4932,4968,6132,6192,6312,6324,6384,6432,6912,6984,8136,8496,8736,9126,9135,9162,9216,9315,9324,9432,9612,9648,9864,12384,12648,12768,12864,13248,13824,13896,13968,14328,14728,14832,16248,16824,17248,18264,18432,18624,18936,19368,21384,21648,21784,21864,23184,24168,24816,26184,27384,28416,29736,31248,31824,31896,31968,32184,34128,36792,37128,37296,37926,38472,39168,39816,41328,41832,42168,42816,43128,43176,46128,46872,48216,48312,61248,61824,62184,64128,68712,72184,73164,73248,73416,73962,78624,79128,79632,81264,81432,81624,81936,82416,84216,84312,84672,87192,89136,89712,91368,91476,91728,92736,93168,93816,98136,123648,123864,123984,124368,126384,129384,132648,132864,132984,134928,136248,136824,138264,138624,139248,139824,142368,143928,146328,146832,148392,148632,149328,149832,162384,163248,163824,164328,164832,167328,167832,168432,172368,183264,183624,184392,184632,186432,189432,192384,193248,193824,194328,194832,198432,213648,213864,213984,214368,216384,218736,219384,231648,231864,231984,234168,234816,236184,238416,239184,241368,243168,243768,243816,247968,248136,248976,261384,263184,273168,281736,283416,284136,291384,293184,297864,312648,312864,312984,314928,316248,316824,318264,318624,319248,319824,321648,321864,321984,324168,324816,326184,328416,329184,341928,342168,342816,346128,348192,348216,348912,349128,361248,361824,361872,362184,364128,364728,367248,376824,381264,381624,382416,384192,384216,384912,391248,391824,392184,394128,412368,413928,416328,416832,418392,418632,419328,419832,421368,423168,423816,427896,428136,428736,431928,432168,432768,432816,436128,438192,438216,438912,439128,461328,461832,463128,468312,469728,478296,478632,481392,481632,482136,483192,483216,483672,483912,486312,489312,491328,491832,493128,498312,612384,613248,613824,613872,614328,614832,618432,621384,623184,623784,627984,631248,631824,632184,634128,634872,641328,641832,643128,648312,671328,671832,681432,684312,689472,732648,732816,742896,746928,762384,768432,783216,789264,796824,813264,813624,814392,814632,816432,819432,823416,824136,824376,831264,831624,832416,834192,834216,834912,836472,841392,841632,842136,843192,843216,843912,846312,849312,861432,864312,873264,891432,894312,897624,912384,913248,913824,914328,914832,918432,921384,923184,927864,931248,931824,932184,934128,941328,941832,943128,948312,976248,978264,981432,984312,1289736,1293768,1369872,1372896,1376928,1382976,1679328,1679832,1687392,1738296,1823976,1863792,1876392,1923768,1936872,1982736,2137968,2138976,2189376,2317896,2789136,2793168,2819376,2831976,2931768,2937816,2978136,2983176,3186792,3187296,3196872,3271968,3297168,3298176,3619728,3678192,3712968,3768912,3796128,3816792,3817296,3867192,3869712,3927168,3928176,6139728,6379128,6387192,6389712,6391728,6719328,6719832,6731928,6893712,6913872,6971328,6971832,7168392,7198632,7231896,7291368,7329168,7361928,7392168,7398216,7613928,7639128,7829136,7836192,7839216,7861392,7863912,7891632,7892136,7916328,7916832,7921368,8123976,8163792,8176392,8219736,8312976,8367912,8617392,8731296,8796312,8912736,8973216,9163728,9176328,9176832,9182376,9231768,9237816,9278136,9283176,9617328,9617832,9678312,9718632,9723168,9781632,9782136,9812376,9867312

```

Which if you run this code with that as the input:

```
nums = length(strsplit(stdout,','))

```

Yeilds 548.
> 3 votes

# Answer
# Ruby, 79

```
?1.upto(?9*7){|s|a=s.chars;a.uniq!||a.any?{|x|x<?1||0<eval([s,x]*?%)}||puts(s)}

```

More interesting but slightly longer solution with a regex:

```
?1.upto(?9*7){|s|s[/(.).*\1|[0#{(1..9).map{|*x|x*eval([s,x]*?%)}*''}]/]||puts(s)}

```

In each case, we're using Ruby's ability to iterate over strings as though they were decimal integers: `?1.upto(?9*7)` is equivalent to `1.upto(9999999).map(&:to_s).each`. We join the string to each nonzero digit using the modulo operator, and eval the result, to check for divisibility.

Bonus Ruby 1.8 solution (requires `-l` flag for proper output):

```
'1'.upto('9'*7){|$_|~/(.).*\1|[0#{(1..9).map{|*x|x*eval("#$_%#{x}")}}]/||print}

```

1.8 allowed the block iterator to be a global variable. Assigning to `$_` makes it the implicit receiver for string operations. We also get to interpolate arrays into the regular expression more easily: in 1.8, `/[#{[1,2]}]/` evaluates to `/[12]/`.
> 3 votes

# Answer
# Javascript (ES6), ~~106~~ ~~90~~ 83 bytes

Kids, don't try this at home; JS will not be happy with the prospect of looping through every digit of every integer from one to ten million with a regex.

```
for(i=0;i<1e7;i++)/(.).*\1|0/.test(i)||+`${i}`.replace(/./g,j=>i%j)||console.log(i)

```

The first regex (props to @Jarmex) returns `true` if the number contains duplicate digits or zeroes. If this turns out `false`, the program move on to the second, which replaces each digit `j` with `i%j`. The result is all zeroes if it's divisible by all of it's digits, in which case it moves on to `console.log(i)`.

Suggestions welcome!
> 3 votes

# Answer
# Ruby, 130 bytes

... not counting whitespace

New to programming,just wanted to participate

```
c=0
(0..10**7).each do |x|
  a=x.to_s.split('')
  c+=1 if !a.include?('0')&& a.uniq!.eql?(nil)&&a.all?{|y| x.modulo(y.to_i).zero?}
end
p c

```
> 3 votes

# Answer
# Pip, 25 bytes

```
Fa,t**7Ia#=UQa&0=$+a%^aPa

```

Outputs each number on its own line. This has been running for about 10 minutes and gotten up to 984312 so far, but I'm pretty sure it's correct. *(Edit: Couple hours later... code finished, generated all 548 of 'em.)*

Here's a Python-esque pseudocode rendition:

```
for a in range(10**7):
  if lengthEqual(a, set(a)) and 0 == sum(a%d for d in digits(a)):
    print(a)

```

The `#=` operator compares two iterables by length. If the number of `U`ni`Q`ue characters in `a` is the same as the number of characters in `a`, there are no repeats.

The divisible-by-each-digit check is from one of my Pip example programs. I wrote it after seeing the earlier challenge, but didn't post it there because the language was newer than the question. Otherwise, at 8 bytes, it would be the winning answer to that question. Here's a step-by-step explanation:

```
      ^a   Split num into an array of its digits
    a%     Take num mod each of those digits; if a digit is zero, the result will be nil
  $+       Sum the resulting list (note: summing a list containing nil results in nil!)
0=         Iff the sum equals 0, return 1 (true); otherwise (>0 or nil), return 0 (false)

```
> 3 votes

# Answer
# JavaScript (ES6), 76

```
/* Answer below. For testing purpose, redirect consoloe.log */ console.log=x=>document.write(x+' ')

for(i=0;i++<1e7;)/0|(.).*\1/.test(i)||[...i+''].some(d=>i%d)||console.log(i)
```

The regexp test for 0 or repeated digits. Then the digits array is checked looking for a non-zero modulo for any digit.

here is the explanation of the 7 digit max.
> 3 votes

# Answer
# C, 122 bytes

```
i,j,m,a;void f(){for(i=1;i<1e8;++i){for(m=0,j=i;j;j/=10){a=j%10;if(!a||m&(1<<a)||i%a)goto n;m|=1<<a;}printf("%d ",i);n:;}}

```

Prettier:

```
i,j,m,a;
void f()
{
    for (i=1; i<1e8; ++i){
        for (m=0, j=i;  j;  j/=10) {
            a = j%10;
            if (!a || m&(1<<a) || i%a)
                goto n;
            m|=1<<a;
        }
        printf("%d ",i);
    n:;
    }
}

```

For each candidate `i`, we iterate its digits `a` in little-endian order, keeping track of seen digits in the bits of `m`. If the loop completes, then all digits are factors of `i` and we saw no zeros or repeated digits, so print it, otherwise we exit early to continue the outer loop.
> 3 votes

# Answer
# gawk, 99 bytes

```
BEGIN{for(;8>(l=split(++i,a,_));printf f?f=_:i RS)for(j in a)f=i~0||i%(d=a[j])||i-d*10^(l-j)~d?1:f}

```

I could reduce that to 97 if I would use `END` instead of `BEGIN`, but then you would have to press Ctrl-D to start the actual output, signalling that there will be no input.

I could reduce it to even 94 if I would write nothing instead of `BEGIN` or `END`, but then you would have to press the return key once to start it, which could be counted as input.

It simply goes over the digits of each number and tests if the criteria are met.

```
i~0               :  number contains a `0`?                          -> trash
i%(d=a[j])        :  number not divisible by current digit?          -> trash
i-d*10^(l-j)~d    :  I removed the current digit from the number yet it
                  :  still contains it?                              -> trash

```

Takes 140 seconds to terminate on my Core 2 Duo.
> 2 votes

# Answer
# CJam, 34 bytes

```
1e7{_:TAb___&=\{T\T)e|%}%:+!**},N*

```
> 2 votes

# Answer
# Lua, 129 bytes

I've eschewed the string approach for pure digit-crunching, which seems a bit speedier and probably saved me some bytes as well. (I'll have test that theory, but Lua string handling is pretty verbose compared to some other languages.)

```
for i=1,1e7 do t={[0]=1}j=i while j>0 do c=j%10 if t[c]or i%c>0 then break end t[c]=1 j=(j-c)/10 if j==0 then print(i)end end end

```
> 2 votes

# Answer
# Jelly, 11 bytes

```
9œ!ṖẎgḌ$ƑƇḌ

```

This uses the two-week old `œ!` atom. Actually fast enough to run on TIO.

Try it online!

### How it works

```
9œ!ṖẎgḌ$ƑƇḌ  Main link. No arguments.

9            Set the return value to 9.
   R         Pop; yield [1, ..., 8].
 œ!          Promote 9 to [1, ..., 9] and generate all permutations of length k,
             each k in the right argument [1, ..., 8].
    Ẏ        Tighten; dump all digit lists in a single array.
         Ƈ   Comb; keep only digit lists for which the link to the left returns 1.
        Ƒ      Fixed; return 1 iff calling the link to the left returns its argument.
       $         Combine the two links to the left into a monadic chain.
      Ḍ            Undecimal; convert the digit list into an integer.
     g             Take the GCD of each digit and the integer.

```
> 2 votes

# Answer
# Japt, ~~21~~ 17 bytes

-4 thanks to Shaggy

```
1e7õ fÈ¥ì_â f myX

```

Try it online!
> 2 votes

# Answer
# PowerShell (reference implementation)

Whoops! Forgot to post this right when I asked the question! I meant to post this as an example / reference implementation, as it's pseudocode-y enough that people should be able to follow the logic. Doesn't seem to serve much purpose now, given the plethora of other answers, but I might as well still post it.

```
for($i=1; $I -le 9867312; $i++){
  $monday=$true
  $index=0
  $num=[char[]]$i.ToString()
  $digits=@()
  while($monday -and $index -lt $num.length){
    switch($num[$index]){
      '0'{$a=0}
      '1'{$a=1}
      '2'{$a=2}
      '3'{$a=3}
      '4'{$a=4}
      '5'{$a=5}
      '6'{$a=6}
      '7'{$a=7}
      '8'{$a=8}
      '9'{$a=9}
    }
    if([array]::IndexOf($digits,$a) -ge 0){ $monday=$false }
    if($a -eq 0){ $monday=$false }
    elseif(($i%$a) -gt 0){ $monday=$false }
    $index++
    $digits+=$a
  }
  if($monday){$i}
}

```
> 1 votes

# Answer
# CJam, 23 bytes

```
1e7{_Ab___|=+:df%:+!},p

```

That's far too slow for the online interpreter, but you can it for a subset: Chrome | Firefox

### Test run

```
$ cjam <(echo '1e7{_Ab___|=+:df%:+!},p') # Output
[1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192 6312 6324 6384 6432 6912 6984 8136 8496 8736 9126 9135 9162 9216 9315 9324 9432 9612 9648 9864 12384 12648 12768 12864 13248 13824 13896 13968 14328 14728 14832 16248 16824 17248 18264 18432 18624 18936 19368 21384 21648 21784 21864 23184 24168 24816 26184 27384 28416 29736 31248 31824 31896 31968 32184 34128 36792 37128 37296 37926 38472 39168 39816 41328 41832 42168 42816 43128 43176 46128 46872 48216 48312 61248 61824 62184 64128 68712 72184 73164 73248 73416 73962 78624 79128 79632 81264 81432 81624 81936 82416 84216 84312 84672 87192 89136 89712 91368 91476 91728 92736 93168 93816 98136 123648 123864 123984 124368 126384 129384 132648 132864 132984 134928 136248 136824 138264 138624 139248 139824 142368 143928 146328 146832 148392 148632 149328 149832 162384 163248 163824 164328 164832 167328 167832 168432 172368 183264 183624 184392 184632 186432 189432 192384 193248 193824 194328 194832 198432 213648 213864 213984 214368 216384 218736 219384 231648 231864 231984 234168 234816 236184 238416 239184 241368 243168 243768 243816 247968 248136 248976 261384 263184 273168 281736 283416 284136 291384 293184 297864 312648 312864 312984 314928 316248 316824 318264 318624 319248 319824 321648 321864 321984 324168 324816 326184 328416 329184 341928 342168 342816 346128 348192 348216 348912 349128 361248 361824 361872 362184 364128 364728 367248 376824 381264 381624 382416 384192 384216 384912 391248 391824 392184 394128 412368 413928 416328 416832 418392 418632 419328 419832 421368 423168 423816 427896 428136 428736 431928 432168 432768 432816 436128 438192 438216 438912 439128 461328 461832 463128 468312 469728 478296 478632 481392 481632 482136 483192 483216 483672 483912 486312 489312 491328 491832 493128 498312 612384 613248 613824 613872 614328 614832 618432 621384 623184 623784 627984 631248 631824 632184 634128 634872 641328 641832 643128 648312 671328 671832 681432 684312 689472 732648 732816 742896 746928 762384 768432 783216 789264 796824 813264 813624 814392 814632 816432 819432 823416 824136 824376 831264 831624 832416 834192 834216 834912 836472 841392 841632 842136 843192 843216 843912 846312 849312 861432 864312 873264 891432 894312 897624 912384 913248 913824 914328 914832 918432 921384 923184 927864 931248 931824 932184 934128 941328 941832 943128 948312 976248 978264 981432 984312 1289736 1293768 1369872 1372896 1376928 1382976 1679328 1679832 1687392 1738296 1823976 1863792 1876392 1923768 1936872 1982736 2137968 2138976 2189376 2317896 2789136 2793168 2819376 2831976 2931768 2937816 2978136 2983176 3186792 3187296 3196872 3271968 3297168 3298176 3619728 3678192 3712968 3768912 3796128 3816792 3817296 3867192 3869712 3927168 3928176 6139728 6379128 6387192 6389712 6391728 6719328 6719832 6731928 6893712 6913872 6971328 6971832 7168392 7198632 7231896 7291368 7329168 7361928 7392168 7398216 7613928 7639128 7829136 7836192 7839216 7861392 7863912 7891632 7892136 7916328 7916832 7921368 8123976 8163792 8176392 8219736 8312976 8367912 8617392 8731296 8796312 8912736 8973216 9163728 9176328 9176832 9182376 9231768 9237816 9278136 9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312]
$ cjam <(echo '1e7{_Ab___|=+:df%:+!},,') # Count
548

```
> 1 votes

# Answer
# Jelly, 13 bytes

```
%DẸ<DQƑ$µ548#

```

(Language is newer than the challenge.)

Try it online!

# Explanation

```
%DẸ<DQƑ$       Helper function: is this a Monday number?
   <             Acts as a “not P and Q” gate here, between:
%D                 Take N modulo each of its digits.
  Ẹ                  Is any truthy? (NaN is truthy.)
                 And:
    DQƑ$           Are the digits are unique (0/1)?

        µ548#  Find the first 548 matches.

```
> 1 votes

# Answer
# APL (Dyalog Unicode), 27 bytesSBCS

Full program.

```
⍸(∧/'0'∘∊<≡∘∪⍨>⍎¨|⍎)∘⍕¨⍳1E9

```

Try it online! (only up to 10⁵ due to run time — change `1E5` to `1E9` for full list)

`⍳1E9`**i**ntegers from 1 to a 10⁹

`(``)∘⍕¨` on the string representation of each:

execute it (giving the original integer back)

`⍎¨|` division remainders of that when divided by the execution of each character of that

…`>` mask for whether the following is greater than each of those:

`≡∘∪⍨` is the character list identical to the **u**nique characters in itself?

…`<` mask for whether the following is less than each of those:

`'0'∘∊` is the character zero a member of the string representation?

`∧/` are those all true? (lit. AND-reduction)

**i**ndices where true
> 1 votes

# Answer
# Common Lisp, 146 bytes

```
(dotimes(i 1e8)(and(equal(setq a(format()"~d"i))(remove-duplicates a))(not(find #\0 a))(every(lambda(x)(=(mod i(-(char-code x)48))0))a)(print i)))

```

Try it online! (where it stops at 3928176 after 60 seconds).
> 1 votes

# Answer
# C, 111

```
h(){int i=0,k,z,m,j;for(;i++<1E7;){for(m=-1,k=i;(z=k%10)&&m&(j=1<<z)&&i%z==0;k/=10,m&=~j);k||printf("%u ",i);}}

```

ungolfed, and partial test:

```
h()
{int i=0,k,z,m,j;
 for(;i++<1E7;)
  {for(m=-1,k=i;(z=k%10)&&m&(j=1<<z)&&i%z==0;k/=10,m&=~j);
   k||printf("%u ",i);
  }
}

main(){h();printf("\n");}

1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192
...
9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312

```

Easy in C...
> 1 votes

# Answer
# APL(NARS), 43 chars, 86 bytes

```
{x/⍨{{0∊⍵:0⋄⍵≢∪⍵:0⋄∧/0=⍵∣w}⍎¨⍕w←⍵}¨x←⍳⍵}1E7

```

here in 45 seconds arrive to 1E5 (not 1E7 as example would pretend) This below would be the translation of one C solution in APL... in 50 seconds it arrive to 3E5

```
r←h;i;j;k;z;m
i←0⋄r←⍬
→0×⍳3E7<i+←1⋄m←9⍴1⋄k←i
→4×⍳0=z←10∣k⋄→2×⍳0=z⊃m⋄→2×⍳0≠z∣i⋄k←⌊k÷10⋄m[z]←0⋄→3
→2×⍳k≠0⋄r←r,i⋄→2

```

in 50 seconds 1..297864 it seems 3 time faster of first function, it would arrive to 1E7 in 28 minutes here.

If it is written the function for doing combination:

```
c←{0≥k←⍺-1:,¨⍵⋄k≥i←≢w←⍵:,¯1⋄↑,/{w[⍵],¨k c w[(⍳i)∼⍳⍵]}¨⍳i-k}

```

and the function for doing permutation:

```
q←{1≥k←≢w←,⍵:⊂,⍵⋄a←⍳k⋄↑,/{w[⍵],¨q w[a∼⍵]}¨a}

```

for build the code for doing the result:

```
↑,/{10⊥¨↑,/(0≠≢¨v)/v←{b/⍨z←{∧/0=⍵∣10⊥⍵}¨b←q⍵}¨⍵ c⍳9}¨⍳7

```

but it runs only in 1 minute and 33 seconds for 1..1E7 it seems the algorithm is faster than the one used above functions (but it not goes below 1 minute, at last here)
> 1 votes

# Answer
# Coffeescript, 83 bytes

No merit for this answer (and therefore **no upvote** please), this is a translation to coffeescript of @ETHproductions solution

```
/(.).*\1|0/.test(i)||+(""+i).replace(/./g,(j)=>i%j)||console.log i for i in[0..1e7]

```

Thanks for your implementation, it helped me to understand some tricks under the hood that can be useful. Wanted to comment your solution but not enough reputation to do that.

Hereafter is also the ES5 solution (101 bytes), running on node.js

```
for(i=1;i<=1e7;i++)/(.).*\1|0/.test(i)||+(""+i).replace(/./g,function(j){return i%j})||console.log(i)

```
> 0 votes

# Answer
# Retina, 77 bytes

*Language postdates challenge*

```
24+%`$
$`$"$`_
%(~`.+
^¶ $.&
\d
*_
)|'0L$` (?!(_+)\b.* \1+$)
$.'
A`0|(.).*\1

```

Try it online!

Note: The TIO link only checks up to 8191, but that is taking 40+ seconds already and the algorithm is at least quadratic in the biggest number it checks in both time and memory. The solution shown above would theoretically check up to 224-1, which includes all Lynch-Bell numbers
> 0 votes

# Answer
# Charcoal, 23 bytes

```
ΦＥＸχ⁷Ｉι∧Πι¬Φι∨⁻μ⌕ιλ﹪κＩλ

```

Try it online! for numbers of up to five digits (too slow for larger numbers). Explanation:

```
   χ                    Predefined variable 10
  Ｘ                     Raised to power
    ⁷                   Literal 7
 Ｅ                      Map over implicit range
      ι                 Current value
     Ｉ                  Cast to string
Φ                       Filter over list of strings
         ι              Current string
        Π               Digital product (is nonzero)
       ∧                Logical And
          ¬             Logical Not
            ι           Current string
           Φ            Filter over digits as characters
               μ         Inner index
              ⁻          Minus
                ⌕        First position of
                  λ      Current character in
                 ι       Current string
             ∨          Logical Or
                    κ   Outer index
                   ﹪    Modulo
                      λ Current character
                     Ｉ  Cast to integer

```
> 0 votes

# Answer
# C# (Visual C# Interactive Compiler), 103 bytes

```
for(int i=0;++i<1e7;)if((i+"").GroupBy(c=>c).All(g=>g.Count()<2&g.Key>48&&i%(g.Key-48)<1))Write(i+" ");

```

Try it online!

To be fair, this started off as RobIII's answer, but it has improved quite a bit.

-5 bytes thanks to @EmbodimentOfIgnorance!

This answer also uses the C# REPL which wasn't quite released at the time that this question was asked.

Less golfed code...

```
// iterate all possible numbers
for(int i=0;++i<1e7;)
  // convert number to string
  if((i+"")
    // group by digits
    .GroupBy(c=>c)
    // ensure each digit only occurs
    // once, the current number is
    // divisible by each digit, and that
    // there are no zeros
    .All(g=>g.Count()<2&
      g.Key>48&&
      i%(g.Key-48)<1
    )
  )
    // print current number if tests pass
    Write(i+" ");

```
> 0 votes

# Answer
# PHP, 140 bytes

```
for(;;$p=1,$n++)if(!in_array(0,$a=str_split($n))&&count($a)==count(array_unique($a))){foreach($a as$b)if($n%$b!=0)$p=0;echo$p==1?"$n ":'';}

```

Usage

```
php -r file.php

```

Output terminal

```
1 2 3 4 5 6 7 8 9 12 15 24 36 48 124 126 128 132 135 162 168 175 184 216 248 264 312 315 324 384 396 412 432 612 624 648 672 728 735 784 816 824 864 936 1236 1248 1296 1326 1362 1368 1395 1632 1692 1764 1824 1926 1935 1962 2136 2184 2196 2316 2364 2436 2916 3126 3162 3168 3195 3216 3264 3276 3492 3612 3624 3648 3816 3864 3915 3924 4128 4172 4236 4368 4392 4632 4872 4896 4932 4968 6132 6192 6312 6324 6384 6432 6912 6984 8136 8496 8736 9126 9135 9162 9216 9315 9324 9432 9612 9648 9864 12384 12648 12768 12864 13248 13824 13896 13968 14328 14728 14832 16248 16824 17248 18264 18432 18624 18936 19368 21384 21648 21784 21864 23184 24168 24816 26184 27384 28416 29736 31248 31824 31896 31968 32184 34128 36792 37128 37296 37926 38472 39168 39816 41328 41832 42168 42816 43128 43176 46128 46872 48216 48312 61248 61824 62184 64128 68712 72184 73164 73248 73416 73962 78624 79128 79632 81264 81432 81624 81936 82416 84216 84312 84672 87192 89136 89712 91368 91476 91728 92736 93168 93816 98136 123648 123864 123984 124368 126384 129384 132648 132864 132984 134928 136248 136824 138264 138624 139248 139824 142368 143928 146328 146832 148392 148632 149328 149832 162384 163248 163824 164328 164832 167328 167832 168432 172368 183264 183624 184392 184632 186432 189432 192384 193248 193824 194328 194832 198432 213648 213864 213984 214368 216384 218736 219384 231648 231864 231984 234168 234816 236184 238416 239184 241368 243168 243768 243816 247968 248136 248976 261384 263184 273168 281736 283416 284136 291384 293184 297864 312648 312864 312984 314928 316248 316824 318264 318624 319248 319824 321648 321864 321984 324168 324816 326184 328416 329184 341928 342168 342816 346128 348192 348216 348912 349128 361248 361824 361872 362184 364128 364728 367248 376824 381264 381624 382416 384192 384216 384912 391248 391824 392184 394128 412368 413928 416328 416832 418392 418632 419328 419832 421368 423168 423816 427896 428136 428736 431928 432168 432768 432816 436128 438192 438216 438912 439128 461328 461832 463128 468312 469728 478296 478632 481392 481632 482136 483192 483216 483672 483912 486312 489312 491328 491832 493128 498312 612384 613248 613824 613872 614328 614832 618432 621384 623184 623784 627984 631248 631824 632184 634128 634872 641328 641832 643128 648312 671328 671832 681432 684312 689472 732648 732816 742896 746928 762384 768432 783216 789264 796824 813264 813624 814392 814632 816432 819432 823416 824136 824376 831264 831624 832416 834192 834216 834912 836472 841392 841632 842136 843192 843216 843912 846312 849312 861432 864312 873264 891432 894312 897624 912384 913248 913824 914328 914832 918432 921384 923184 927864 931248 931824 932184 934128 941328 941832 943128 948312 976248 978264 981432 984312 1289736 1293768 1369872 1372896 1376928 1382976 1679328 1679832 1687392 1738296 1823976 1863792 1876392 1923768 1936872 1982736 2137968 2138976 2189376 2317896 2789136 2793168 2819376 2831976 2931768 2937816 2978136 2983176 3186792 3187296 3196872 3271968 3297168 3298176 3619728 3678192 3712968 3768912 3796128 3816792 3817296 3867192 3869712 3927168 3928176 6139728 6379128 6387192 6389712 6391728 6719328 6719832 6731928 6893712 6913872 6971328 6971832 7168392 7198632 7231896 7291368 7329168 7361928 7392168 7398216 7613928 7639128 7829136 7836192 7839216 7861392 7863912 7891632 7892136 7916328 7916832 7921368 8123976 8163792 8176392 8219736 8312976 8367912 8617392 8731296 8796312 8912736 8973216 9163728 9176328 9176832 9182376 9231768 9237816 9278136 9283176 9617328 9617832 9678312 9718632 9723168 9781632 9782136 9812376 9867312

```

Test Online
> 0 votes

# Answer
# Perl 6, 42 bytes

```
put grep {!/(.).*$0/&&$_%%+.comb.all},^1e7

```

Try it online!

A full program that creates a bunch of warnings, but eventually goes through. Times out on TIO, but you can test it by changing the final range, for example 1000.

### Explanation:

```
    grep {                          },^1e7    # Filter from the range 0 to 10000000
          !/(.).*$0/       # The number does not contain duplicate digits
                    &&     # And
                      $_%%             # The number is divisible by
                                 .all  # all of
                           +.comb      # The digits of the number
                                       # Note that $_%%0 is False
put  # And print the list

```
> 0 votes

# Answer
# C# (Visual C# Interactive Compiler), 84 bytes

```
for(int i=0;++i<1e7;)if((i+"").All(c=>i%(c-48d)<1&(i+"").Count(x=>x==c)<2))Print(i);

```

Saved a byte thanks to ceilingcat

Try it online!
> 0 votes

# Answer
## K 44 Bytes

```
&{(&/x=b*_x%b)&(b~?b)&x&~0 in b:10\:x}'!_1e7

```
* `_1e7` generates 0..9999999
* `&{..}'!_1e7` applies lambda to each 0.9999999 and prints indexes where lambda is true
* Lambda has four expressions `(..)&(..)&..&..` and return true if each .. is true (`&` is and)
* `b:10\:x` set b to decimal digits of argument x
* `~0 in b` reads "not 0 in b"
* `x&~0 in b` true if x is not 0 and not 0-digit in b. `x&` is necessary because 10:0 generates empty digits list instead of list with digit 0
* `b~?b` reads as "b match unique b", and its true iff non-repeated digits in b
* `_x%b` reads as "floor of x dividedBy each item of b"
* `&/x=b*_x%b` reads "all x = digits * quotient of integer divission"
> 0 votes

# Answer
# Julia, 79 bytes

```
join(filter(k->(d=digits(k))==unique(d)&&(l=lcm(d))>0&&k%l<1,1:6^9)," ")|>print
```

Attempt This Online!

or in the same size:

```
join([k for k=1:6^9if(d=digits(k))==unique(d)&&(l=lcm(d))>0&&k%l<1]," ")|>print

```
> 0 votes

# Answer
# Vyxal, 9 bytes

```
7↵'f$ġnU⁼

```

Try it Online! (modified to only output numbers up to \\$10^3\\$ instead of \\$10^7\\$ to prevent timeouts)
> 0 votes

# Answer
# JavaScript (V8), 60 bytes

```
for(i=0;i++<1e7;)[...i+''].every(y=e=>y[e]^=i%e<1)&&print(i)

```

Try it online!

Same idea, also mine
> 0 votes

---
Tags: code-golf, number, sequence
---


title: Minecraft XP Orb Amounts

text:
# Question
Title: Minecraft XP Orb Amounts
In the video game *Minecraft*, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the player various amounts of XP. The possible orbs are shown in the image below, along with the smallest and largest amount of XP that orb can contain:

Source

In this challenge, you should output (as a finite sequence) the minimum units of XP that these orbs can contain; specifically, output the sequence

```
-32768
3
7
17
37
73
149
307
617
1237
2477

```

Standard loopholes are forbidden. As this is , the shortest program wins.

# Answer
> 10 votes
# JavaScript (Node.js), 37 bytes

```
n=>2.42*2**n-'21221452221'[n]|-!n<<15

```

Try it online!

# Answer
> 5 votes
# JavaScript (ES6), 39 bytes

Expects an integer \\$n\\$ and returns the \\$n\\$-th term, 0-indexed.

```
n=>309<<n>>7^"50954381462"[n]^7||-32768

```

Try it online!

---

# JavaScript (ES6), 46 bytes

The obvious method that returns a hard-coded array.

```
_=>[-32768,3,7,17,37,73,149,307,617,1237,2477]

```

Try it online!

# Answer
> 4 votes
# Jelly, 16 bytes

```
“Ḣƈ¤’b6ḄƤ+.⁽Ṭḥ;Ḥ

```

Try it online!

Outputs the full sequence, with trailing `.0`s due to a horrifyingly scuffed golf on the only way I could figure out how to compress `-32768` that doesn't only break even as chained.

Based on the common doubling observation, this abuses the binary conversion builtin to compress a pattern in the *maxima* rather than the minima; before figuring out the `+.` trick `“Ŀ¶ƈR’Do-ḄƤ⁽ṬḥḤ¤;` tied (with `“Ḣƈ¤’b6ḄƤḤ‘⁽ṬḥḤ¤;`) by compressing the same pattern for the minima directly.

```
“Ḣƈ¤’               12414254
     b6             converted to base 6:
“Ḣƈ¤’b6             [1, 1, 2, 2, 0, 2, 5, 2, 2, 2].
       ḄƤ           "Convert" each prefix "from binary";
       Ḅ            i.e. multiply and sum with powers of 2.
         +.         Add 0.5 to each result,
           ⁽Ṭḥ;     prepend -16384,
               Ḥ    and double.

```

# Answer
> 4 votes
# Nibbles, 14 bytes (28 nibbles)

```
:-32768 +~ =\ `D6 *+@$~ 157332e

```

Attempt This Online!

Similar 'difference-from-doubling-sequence' concept to leo848's answer & unrelated string's answer, but slightly different logic at each step.

```
:-32768 +~ =\ `D6 *+@$~ 157332e
              `D6       157332e  # convert from base-6
                                 # to get:
                                 # [2,1,2,2,0,2,5,2,2,2];
           =\                    # now scan across this,
                   +@$           #   adding each number to result-so-far
                  *   ~          #   and doubling
        +~                       # add 1 to every element
:-32768                          # and prepend -32768

```

(Trivial compression would be 20.5 bytes)

# Answer
> 3 votes
# Rust, 49 bytes

Trivial solution. Takes a number and returns the sequence at that index.

```
|i|[-32768,3,7,17,37,73,149,307,617,1237,2477][i]

```

Attempt This Online!

# Rust, 76 bytes

Nontrivial solution. Relies on the fact that the numbers mostly double and then add to a fixed amount. This array could perhaps be golfed more, or be constructed in a different way. The `scan` also looks like it could be shortened somehow. Returns an iterator that contains the sequence.

```
||[-32768,65539,1,3,3,-1,3,9,3,3,3].iter().scan(0,|s,x|{*s=*s*2+x;Some(*s)})

```

Attempt This Online!

# Rust, 67 bytes

Same approach, but uses `fold` to automatically exhaust the iterator. Yes, the extra `3` is there on purpose although the value of the number is irrelevant. The output is cluttered with line numbers and debug stuff though, I am not aware on the consensus of this for .

```
||[65539,1,3,3,-1,3,9,3,3,3,3].iter().fold(-32768,|s,x|dbg!(s)*2+x)

```

Attempt This Online!

# Answer
> 3 votes
# 05AB1E, ~~15~~ 14 bytes

```
•δ«иé•ηC·>žG(š

```

-1 byte thanks to *@CommandMaster*.

Try it online.

**Explanation:**

```
•δ«иé•         # Push compressed integer 1122025222
      η        # Pop and push a list of its prefixes
       C       # Convert each prefix from a binary-string to a base-10 integer
        ·      # Double each
         >     # Increase each by 1
          žG   # Push builtin integer 32768
            (  # Negate it
             š # Prepend this -32678 to the list
               # (after which the list is output implicitly as result)

```

See this 05AB1E tip of mine (section *How to compress large integers?*) to understand why `•δ«иé•` is `1122025222`.

# Answer
> 2 votes
# ARBLE, 40 bytes

```
-2^15,3,7,17,37,73,149,307,617,1237,2477

```

Ultra trivial solution. Outputs the first number with a trailing `.0`

Try it online!

# Answer
> 2 votes
# Charcoal, 23 bytes

```
⁺-”)‴⧴1³∧◨¤›✂⊗＆→⁵⊖；⁹WＴ∧

```

Try it online! Link is to verbose version of code. Outputs the entire sequence. Explanation: Simply compressing the whole string would have taken 27 bytes, but removal of the leading `-` allows Charcoal to compress the remainder into a 22-byte string (21 without the trailing delimiter) and then two bytes are used to prefix the `-` again.

Without string compression, the best I can do is ~~31~~ to port @UnrelatedString's Jelly answer for 26 bytes:

```
-32768¶ＩＥχ⍘⪫11…122025222ι²

```

Attempt This Online! Link is to verbose version of code. Outputs the entire sequence. Explanation:

```
-32768¶                     Literal string `-32768\n`
                            Implicitly print
         χ                  Predefined variable `10`
        Ｅ                   Map over implicit range
            11              Literal string `11`
           ⪫                Join characters with
               122025222    Literal string `122025222`
              …             Truncated to length
                        ι   Current value
          ⍘                 Converted from "base"
                         ²  Literal integer `2`
       Ｉ                    Cast to string
                            Implicitly print

```

My previous 31-byte answer translated into a 40-byte ES6 solution, which has since been beaten by a couple of similar-looking answers:

```
f=
n=>n--?(155<<n>>5)-"1221463333"[n]:n<<15
```

```
<input type=number min=0 max=10 oninput=o.textContent=f(this.value)><pre id=o>
```

Returns the `n`th value (`0`-indexed).

# Answer
> 2 votes
# MathGolf, 20 bytes

```
cE#37FY_x5ò_∞ï┴)3▬+]

```

Try it online.

**Explanation:**

```
c          # Push -2
 E         # Push 15
  #        # Pop both, and push -2**15: -32768
3          # Push 3
7          # Push 7
F          # Push 17
Y          # Push 37
_          # Duplicate the 37
 x         # Pop and reverse it to 73
5ò         # Loop 5 times,
 ò         # using the following eight characters as inner code-block:
  _        #  Duplicate the top
   ∞       #  Pop and double it
    ï      #  Push the 0-based index
     ┴     #  Check whether it's equal to 1 (1 if index=1; 0 otherwise)
      )    #  Increase it by 1 (2 if index=1; 1 otherwise)
       3   #  Push a 3
        ▬  #  Pop both, and push 3**((index==1)+1)
         + #  Add it to the doubled value
]          # Wrap all values on the stack into a list
           # (after which the entire stack is output implicitly as result)

```

---
Tags: code-golf, sequence, kolmogorov-complexity
---