# Crack the Lost Numbers

The Lost Numbers are 4, 8, 15, 16, 23, 42. Your goal is to create an expression to output them all.

Your allowed characters are 0123456789, ^+-*/, (), % for modulo and n as the single variable allowed. Modified PEMDAS ()^*/%+- is the precedence and / is normal division (3/2 = 1.5). 0^0 = 1 although division by 0 is undefined.

Create the shortest expression (in characters) such that for n = 0..5 (or 1..6 for 1-indexing) the nth Lost Number will be the result of the expression. Shortest expression wins.

• What if the language can't handle the size of the number :P?
– math
Jul 1 at 13:14
• Relevant OEIS
– user100752
Jul 1 at 13:23
• What's the precedence of the operators? (e.g. does 17%4*3 evaluate as 3 or 5?) Jul 1 at 13:58
• Parentheses Exponents Multiply Divide Add Subtract Jul 1 at 14:02
• @Arnauld edited post to clarify precedence Jul 1 at 14:18

# 20 characters

Assuming that the precedence of the operators is similar to JS. The input is expected to be 1-indexed.

n*4+16%n*3+6*0^(6-n)


Try it online! (interpreted in JS ES7)

### Breakdown

 n           |  1 |  2 |  3 |  4 |  5 |  6 | (x4)
16 % n      |  0 |  0 |  1 |  0 |  1 |  4 | (x3)
0 ^ (6 - n) |  0 |  0 |  0 |  0 |  0 |  1 | (x6)
-------------+----+----+----+----+----+----+------
|  4 |  8 | 15 | 16 | 23 | 42 |

• Brilliant! It looks like n*4+16%n*8%13%7*3 works.
– Lynn
Jul 1 at 16:10
• @Lynn This is clearly pushing it a step further, so feel free to post it as a new answer. Jul 1 at 16:12

# 16 15 characters

6704196%(n*8+3)

One-indexed. A simple application of a generalisation of the Chinese Remainder Theorem, with the formula n*8+3 chosen to make it work (that is, where moduli have a common factor, the corresponding values' difference is also divisible by that factor), as well as to get a shorter number on the left.

Previously: 485559068%(n+41), zero-indexed

• Have you tried expressions of the form a%(b-n)?
– Neil
Jul 1 at 17:01
• @Neil I just tried that, and found nothing better than the original from it.
– m90
Jul 1 at 17:49

# 15 bytes

n*4+703%n^3%7*3


Try it online!

The idea was to look for a magic formula A%n^B%C that maps (1, 2, 3, 4, 5, 6) to (0, 0, 1, 0, 1, 6) to combine the last two terms in Arnauld's formula into one:
 n           |  1 |  2 |  3 |  4 |  5 |  6 | (x4)