Skip to main content
Commonmark migration
Source Link

05AB1E, 9 bytes

1=IGx^Db,

Try it online!

The number of rows is equal to the input.

#Explanation:

Explanation:

1=IGx^Db,
1=         print "1" and push 1
  IG       for N in range(1, I): (where I is the input)
    x      push last element on stack multiplied by 2
     ^     pop last two elements, push their bitwise xor (output is in decimal)
      D    duplicate last element of stack
       b,  replace last element of stack with its binary representation, then print/pop

This takes advantage of the fact that a(n+1) = a(n) XOR 2*a(n), which I found on this relevant OEIS page

05AB1E, 9 bytes

1=IGx^Db,

Try it online!

The number of rows is equal to the input.

#Explanation:

1=IGx^Db,
1=         print "1" and push 1
  IG       for N in range(1, I): (where I is the input)
    x      push last element on stack multiplied by 2
     ^     pop last two elements, push their bitwise xor (output is in decimal)
      D    duplicate last element of stack
       b,  replace last element of stack with its binary representation, then print/pop

This takes advantage of the fact that a(n+1) = a(n) XOR 2*a(n), which I found on this relevant OEIS page

05AB1E, 9 bytes

1=IGx^Db,

Try it online!

The number of rows is equal to the input.

Explanation:

1=IGx^Db,
1=         print "1" and push 1
  IG       for N in range(1, I): (where I is the input)
    x      push last element on stack multiplied by 2
     ^     pop last two elements, push their bitwise xor (output is in decimal)
      D    duplicate last element of stack
       b,  replace last element of stack with its binary representation, then print/pop

This takes advantage of the fact that a(n+1) = a(n) XOR 2*a(n), which I found on this relevant OEIS page

Source Link
golf69
  • 2.1k
  • 1
  • 15
  • 31

05AB1E, 9 bytes

1=IGx^Db,

Try it online!

The number of rows is equal to the input.

#Explanation:

1=IGx^Db,
1=         print "1" and push 1
  IG       for N in range(1, I): (where I is the input)
    x      push last element on stack multiplied by 2
     ^     pop last two elements, push their bitwise xor (output is in decimal)
      D    duplicate last element of stack
       b,  replace last element of stack with its binary representation, then print/pop

This takes advantage of the fact that a(n+1) = a(n) XOR 2*a(n), which I found on this relevant OEIS page