Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

add better TIO links, one for a specific term and another for the first 100 terms
Source Link
RGS
  • 14.2k
  • 1
  • 62
  • 117

Jelly, 4 bytes

BTịD

Try it online , code that computes the \$n\$th term of the sequence, or Try it onlinecheck the first 100 terms!

How it works:

B convert number to binary, i.e. 5 -> [1, 0, 1]
 T keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
 ị and then index safely into...
 D the decimal digits of the input number

By "index safely" I mean that indices out of range are automatically converted into the correct range!

Jelly, 4 bytes

BTịD

Try it online!

How it works:

B convert number to binary, i.e. 5 -> [1, 0, 1]
 T keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
 ị and then index safely into...
 D the decimal digits of the input number

By "index safely" I mean that indices out of range are automatically converted into the correct range!

Jelly, 4 bytes

BTịD

Try it online , code that computes the \$n\$th term of the sequence, or check the first 100 terms!

How it works:

B convert number to binary, i.e. 5 -> [1, 0, 1]
 T keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
 ị and then index safely into...
 D the decimal digits of the input number

By "index safely" I mean that indices out of range are automatically converted into the correct range!

added 354 characters in body
Source Link
RGS
  • 14.2k
  • 1
  • 62
  • 117

Jelly, 4 bytes

BTịD

Try it online! Try it online!

How it works:

B convert number to binary, i.e. 5 -> [1, 0, 1]
 T keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
 ị and then index safely into...
 D the decimal digits of the input number

By "index safely" I mean that indices out of range are automatically converted into the correct range!

Jelly, 4 bytes

BTịD

Try it online!

Jelly, 4 bytes

BTịD

Try it online!

How it works:

B convert number to binary, i.e. 5 -> [1, 0, 1]
 T keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
 ị and then index safely into...
 D the decimal digits of the input number

By "index safely" I mean that indices out of range are automatically converted into the correct range!

Source Link
RGS
  • 14.2k
  • 1
  • 62
  • 117

Jelly, 4 bytes

BTịD

Try it online!

AltStyle によって変換されたページ (->オリジナル) /