15

Find the rule between these numbers and their brackets sequences.

1 = not defined
2 = <>
3 = <<>>
4 = <><>
5 = <<<>>>
6 = <><<>>
7 = <<><>>
8 = <><><>
9 = <<>><<>>
10 = <><<<>>>
11 = <<<<>>>>
12 = <><><<>>
13 = <<><<>>>
14 = <><<><>>
15 = <<>><<<>>>
16 = <><><><>
17 = <<<><>>>
18 = <><<>><<>>
19 = <<><><>>
20 = <><><<<>>>
...

Note: Every number bigger than 1 can be written like this.

I got this puzzle from my friend.

Jamal Senjaya
  • 17,864
  • 2
  • 41
  • 147

2 Answers2

14

As @lois6b has already found out, numbers can be multiplied by juxtaposing their bracket representations: 6 = 2×3, so the bracket representation is the representation of 2 next the representation of 3, <> <<>>. The first factor is the smallest factor, usually a small prime.

Primes cannot be gerenated in that fashion, so there is a special rule for them: The nth prime is represented by <n>, that is the bracket representation of n enclosed in brackets.

Here's a small Python program that prints the list above:

rep = ["", ""]
primes = []

def smallfact(n):
    for p in primes:
        if n % p == 0:
            return p
    return 1

for n in range(2, 21):
    s = smallfact(n)

    if s == 1:
        primes.append(n)
        rep.append("<" + rep[len(primes)] + ">")

    else:
        rep.append(rep[s] + rep[n / s])

    print n, '=', rep[-1]
M Oehm
  • 60,621
  • 3
  • 208
  • 271
7

answer: (update)

The prime numbers are nth prime seems to be encoded as <n>, so 5, which is the 3rd prime number is <<<>>> (thanks to M Oehm :* )
2 is <n> -> <1> -> <>

The even numbers are product of other numbers:
10 = <><<<>>> -> because <>(2) * <<<>>> (5) = 10
20 = <><><<<>>> -> because <><> (4) * <<<>>> (5) = 20

lois6b
  • 3,346
  • 21
  • 41