[Question]
  [
The [dragon curve sequence](http://oeis.org/A014577) (or the regular paper folding sequence) is a binary sequence. `a(n)` is given by negation of the bit left of the least significant 1 of `n`. For example to calculate `a(2136)` we first convert to binary:
```
100001011000
```
We find our least significant bit
```
100001011000
        ^
```
Take the bit to its left
```
100001011000
       ^
```
And return its negation
```
0
```
# Task
Given a positive integer as input, output `a(n)`. (You may output by integer or by boolean). You should aim to make your code as small as possible as measured by bytes.
# Test Cases
Here are the first 100 entries in order
```
1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 1
```
  
[Answer]
## Mathematica 25 Bytes
```
1/2+JacobiSymbol[-1,#]/2&
```
Other ways of doing this:
56 bytes
```
(v:=1-IntegerDigits[#,2,i][[1]];For[i=1,v>0,i++];i++;v)&
```
58 bytes
```
1-Nest[Join[#,{0},Reverse[1-#]]&,{0},Floor@Log[2,#]][[#]]&
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~22~~ 21 bytes
1 byte thanks to ETHproductions.
```
lambda n:n&2*(n&-n)<1
```
[Try it online!](https://tio.run/##RcixCoAgFAXQva94U/nKQBMapP6kxShLqJuIS19vY2c88c3nA1P8vJTL3evmCBb10ArUPXjSxT@JAgVQcjh2oaVWim1MAVmozovAcsc2N9Rw9e@gzchcPg "Python 3 – Try It Online")
Bitwise arithmetic ftw.
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~38~~ ~~34~~ 29 bytes
```
\d+
$*
+`^(1+)\1$|1111
$1
^1$
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wPyZFm0tFi0s7IU7DUFszxlClxhAIuFQMueIMVf7/N@Qy4jLmMuEy5TLjMuey4LLkMjTgMjI0NgMA "Retina – Try It Online")
Martin and Leaky essentially came up with this idea, for 5 more bytes off!
Converts the input to unary, and then progressively divides the number by 2. Once it can't do that evenly anymore (i.e. the number is odd) it then removes patches of 4 from the input, computing the result of the last operation mod 4. Finally, this checks if the result was 1, which means that digit to the left of the least significant 1 bit was zero. If that is true, the final result is 1, otherwise it is zero.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
&N&HṆ
```
[Try it online!](https://tio.run/##y0rNyan8/1/NT83j4c62/4YGBofbHzWt8f4PAA "Jelly – Try It Online")
### How it works
```
&N&HṆ  Main link. Argument: n
 N     Negate; yield -n.
&      Bitwise AND; compute n&-n.
       This yields the highest power of 2 that divides n evenly.
   H   Halve; yield n/2.
  &    Bitwise AND; compute n&-n&n/2. This rounds n/2 down if n is odd.
    Ṇ  Take the logical NOT of the result.
```
[Answer]
## [Alice](https://github.com/m-ender/alice), 8 bytes
```
I2z1xnO@
```
[Try it online!](https://tio.run/##S8zJTE79/9/TqMqwIs/f4f//BwtnAAA "Alice – Try It Online")
Takes input [as the code point of a Unicode character](http://meta.codegolf.stackexchange.com/questions/4708/can-numeric-input-output-be-in-the-form-of-byte-values) and outputs the result as a 0x00 or 0x01 byte accordingly.
For testability, here is a decimal I/O version at 12 bytes which uses the exact same algorithm (only I/O is different):
```
/o
\i@/2z1xn
```
[Try it online!](https://tio.run/##S8zJTE79/18/nysm00HfqMqwIu//fyNDYzMA "Alice – Try It Online")
If Alice was a golfing language and didn't require explicit I/O and program termination, this would clock in at a mere 5 bytes (`2z1xn`) beating both 05AB1E and Jelly.
### Explanation
```
I    Read input.
2z   Drop all factors of 2 from the input, i.e. divide it by 2 as long
     as its even. This shifts the binary representation to the right
     until there are no more trailing zeros.
1x   Extract the second-least significant bit.
n    Negate it.
O    Output it.
@    Terminate the program.
```
[Answer]
# [Haskell](https://www.haskell.org/), 33 bytes
```
g~(a:b:c)=1:a:0:b:g c
d=g d
(d!!)
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P71OI9EqySpZ09bQKtHKAMhMV0jmSrFNV0jhSrPVSFFU1Pyfm5iZp2CrUFCUmVeioJGbWKCQphBtoKdnaRmr@R8A "Haskell – Try It Online")
Uses 0-indexing.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~24 23~~ 21 bytes
```
{~⍵[¯1+⌈/⍸⍵]}0,2⊥⍣¯1⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v7ruUe/W6EPrDbUf9XToP@rdAeTG1hroGD3qWvqodzFQ4lHXov9pj9omPOrte9TV/Kh3zaPeLYfWGz9qm/iob2pwkDOQDPHwDP6fdmjFo97NhgYGAA "APL (Dyalog Unicode) – Try It Online")
Bitwise operations are a bit long in APL, so I went with the method in the question.
-1 byte from dzaima.
-2 bytes from Adám.
## Explanation
```
{~⍵[¯1+⌈/⍸⍵]}0,2⊥⍣¯1⊢ input n taken on the right
               2⊥⍣¯1⊢ n in binary
             0,       with 0 prepended in case the LSB is at first index
{           }         do the following to the array ⍵:
         ⍸⍵           get indices of 1's in ⍵
       ⌈/             find maximum index
    ¯1+               subtract 1 from it to get the previous index
  ⍵[       ]          Find the element at that index in ⍵
 ~                    bitwise NOT
```
[Answer]
# [Haskell](https://www.haskell.org/), 26 bytes
```
f n=even$div n$2*gcd(2^n)n
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hzza1LDVPJSWzTCFPxUgrPTlFwyguTzPvf25iZp6CrUJBUWZeiYKKQm5igUKaQrShnp6pQex/AA "Haskell – Try It Online")
Boolean output.
**32 bytes**
```
(d!!)
d=d%1
~(h:t)%k=k:h:t%(1-k)
```
[Try it online!](https://tio.run/##y0gszk7NyfmfZhvzXyNFUVGTK8U2RdWQq04jw6pEUzXbNtsKyFDVMNTN1vyfm5iZp2CrUFCUmVeioJGbWKCQphBtoKdnaRmr@f9fclpOYnrxf93kggIA "Haskell – Try It Online")
Saves one byte off of [Anders Kaseorg's recursive-list solution](https://codegolf.stackexchange.com/a/132818/20260).
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
```
b0Ü¨θ≠
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/yeDwnEMrzu141Lng/38jQ2MzAA "05AB1E – Try It Online")
[Answer]
# [Wise](https://github.com/Wheatwizard/Wise), ~~28~~ ~~20~~ 16 bytes
```
::-~^~-&:[?>]~-^
```
[Try it online!](https://tio.run/##K88sTv3/36rOyiquTtfKXi3aKi7OzqpOEciMjatTtFGz@///v6ExAA "Wise – Try It Online")
## Explanation
This is a port of Leaky Nun's Python answer. It unfortunately does not work on TIO because TIO's version of the interpreter is a bit outdated.
We start by making 3 copies of our input with `::`, we then decrement the top copy by 1. This will flip all the bits up until the first 1. We then xor this with another copy of our input. Since all of the bits up until the first 1 on our input have been flipped this will result in all those bits being 1 on the result. If we then add one `~-` to the result we will get a single 1 at the place *to the left of* our least significant 1. We AND this with the input to get that bit from the input. Now we will have `0` iff that bit was off and a power of 2 iff that bit was on, we can change this into a single `1` or `0` with `:[?>]`. Once this is done we need only negate the bit `~-^` and we are done.
[Answer]
# [Python 2](https://docs.python.org/2/), 19 bytes
```
lambda n:n&-n&n/2<1
```
[Try it online!](https://tio.run/##BcFBCoAgEAXQq/yVOFDUuJQuY2Ql1FfETaef3mvfuCuDnbWDKERPvLLXCbqqRLReOODtSe9@JDDSzXRcwqYmnmI/ "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~45~~ ~~43~~ 39 bytes
*6 bytes saved thanks to nimi*
```
f x|d<-div x 2=[f d,mod(1+d)2]!!mod x 2
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P02hoibFRjcls0yhQsHINjpNIUUnNz9Fw1A7RdMoVlERyAZJ/M9NzMyzLSgtCS4pUknOz0tOLFGJVldQtyrOyC8HGlFho5ubWKCQFm2op2doYBAb@x8A "Haskell – Try It Online")
[Answer]
# x86 Machine Code, ~~17~~ ~~16~~ 15 bytes:
Assumes an ABI where parameters are pushed on the stack and the return value is in the `AL` register.
```
8B 44 24 04 0F BC C8 41 0F BB C8 0F 93 C0 C3
```
This is disassembled as follows:
```
_dragoncurve:
  00000000: 8B 44 24 04        mov         eax,dword ptr [esp+4]
  00000004: 0F BC C8           bsf         ecx,eax
  00000007: 41                 inc         ecx
  00000008: 0F BB C8           btc         eax,ecx
  0000000B: 0F 93 C0           setae       al
  0000000E: C3                 ret
```
[Answer]
## JavaScript (ES6), ~~17~~ 14 bytes
```
f=
n=>!(n&-n&n/2)
```
```
<input type=number min=0 oninput=o.textContent=f(this.value)><pre id=o>
```
Edit: Saved 3 bytes by porting @Dennis's answer once I noticed that boolean output was acceptable.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 20 bytes
```
f(n){n=!(n&-n&n/2);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z9NI0@zOs9WUSNPTTdPLU/fSNO69n9mXolCbmJmnoYmVzUXZ1p@kQZIJE/BVsHQGkjZAGkDAyBLW1uTi5OzoAgom6ahpFqqoKSjADJQ05qrlus/AA "C (gcc) – Try It Online")
[Answer]
# [INTERCAL](https://esolangs.org/wiki/INTERCAL), 50 bytes
```
DOWRITEIN.1DO.1<-!?1~.1'~#1DOREADOUT.1PLEASEGIVEUP
```
INTERCALs unary operators are quite suitable for this, so I decided to write my first post.
```
DO WRITE IN .1
DO .1 <- !?1~.1'~#1
DO READ OUT .1
PLEASE GIVE UP
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 6 bytes
1 byte thanks to Erik the Outgolfer.
```
Bt0ṖṪṆ
```
[Try it online!](https://tio.run/##AR0A4v9qZWxsef//QnQw4bmW4bmq4bmG/zk5w4figqxH/w "Jelly – Try It Online")
## Longer programs
* 7 bytes: [`Họ¡2&2Ị`](https://tio.run/##y0rNyan8/9/j4e7eQwuN1Iwe7u76b2l5uP1R0xr3/wA)
* 7 bytes: [`Bt0ṫ-ḄỊ`](https://tio.run/##y0rNyan8/9@pxODhztW6D3e0PNzd9d/S8nD7o6Y17v8B)
[Answer]
# [Befunge-98](https://github.com/catseye/FBBI), 19 bytes
```
&#;:2%\2/\#;_;@.!%2
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tPj/X03Z2spINcZIP0bZOt7aQU9R1ej/fyNDYzMA "Befunge-98 – Try It Online")
```
&#                       Initial input: Read a number an skip the next command
  ;:2%\2/\#;_;           Main loop: (Direction: East)
   :2%                    Duplicate the current number and read the last bit
      \2/                 Swap the first two items on stack (last bit and number)
                          and divide the number by two => remove last bit
         \                swap last bit and number again
          #;_;            If the last bit is 0, keep going East and jump to the beginning of the loop
                          If the last bit is 1, turn West and jump to the beginning of the loop, but in a different direction.
&#;           @.!%2      End: (Direction: West)
&#                        Jump over the input, wrap around
                 %2       Take the number mod 2 => read the last bit
               .!         Negate the bit and print as a number
              @          Terminate
```
[Answer]
# [,,,](https://github.com/totallyhuman/commata), ~~10~~ 9 [bytes](https://github.com/totallyhuman/commata/wiki/Code-page)
```
::0-&2*&¬
```
## Explanation
Take input as 3 for example.
```
::0-&2*&1≥
               implicitly push command line argument       [3]
::             duplicate twice                             [3, 3, 3]
  0            push 0 on to the stack                      [3, 3, 3, 0]
   -           pop 0 and 3 and push 0 - 3                  [3, 3, -3]
    &          pop -3 and 3 and push -3 & 3 (bitwise AND)  [3, 1]
     2         push 2 on to the stack                      [3, 1, 2]
      *        pop 2 and 1 and push 2 * 1                  [3, 2]
       &       pop 2 and 3 and push 2 & 3                  [2]
        ¬      pop 2 and push ¬ 2 (logical NOT)            [0]
               implicit output                             []
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 34 bytes
```
@(x)~(k=[de2bi(x),0])(find(k,1)+1)
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzTiPbNjol1SgpE8jRMYjV1EjLzEvRyNYx1NQ21PyfpmFooPkfAA "Octave – Try It Online")
**Explanation:**
```
@(x)                               % Anonymous function taking a decimal number as input
    ~....                          % Negate whatever comes next
     (   de2bi(x)   )              % Convert x to a binary array that's conveniently 
                                   % ordered with the least significant bits first
        [de2bi(x),0]               % Append a zero to the end, to avoid out of bound index
     (k=[de2bi(x),0])              % Store the vector as a variable 'k'
                     (find(k,1)    % Find the first '1' in k (the least significant 1-bit)
                               +1  % Add 1 to the index to get the next bit
     (k=[de2bi(x),0])(find(k,1)+1) % Use as index to the vector k to get the correct bit
```
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 71 bytes
```
(load library
(q((x)(not(nth(c 0(to-base 2 x))(last-index(to-base 2 x)1
```
Anonymous function that takes a number and returns 0 or 1. [Try it online!](https://tio.run/##VckxDoAgDAXQ3VN0/B1IkEtwjiImkiAgdMDT4@xbn6by5jTaWshVIuUUuvR3QySPB5iMUhVFLxxkodUEGSc5mszIMtSkEs/5i33hlkaesGslZ5nXBw "tinylisp – Try It Online")
### Ungolfed/explanation
Surprisingly, tinylisp's library lets us implement the spec almost directly.
```
(load library)
(lambda (x)                   ; Anonymous function with one argument
  (not                        ; Logical negation of
    (nth                      ; The element of _ at index __:
      (cons 0 (to-base 2 x))  ; The binary representation of x with a 0 prepended
      (last-index             ; Index of the last occurrence
        (to-base 2 x)         ; in the binary representation of x
        1)))))                ; of 1
```
Prepending a 0 handles the "previous bit" logic by shifting all elements down one spot, and it keeps us from walking off the left end of the list when there is only a single 1 bit.
[Answer]
# Submission:
# [Python 2](https://docs.python.org/2/), ~~41~~ 39 bytes
```
x=input()
while~-x&1:x/=2
print 1-x/2%2
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v8I2M6@gtERDk6s8IzMntU63Qs3QqkLf1oiroCgzr0TBULdC30gVqNDI0NgMAA "Python 2 – Try It Online")
-2 bytes thanks to FryAmTheEggman
# Initial Solution:
# [Python 2](https://docs.python.org/2/), 43 bytes
```
lambda x:1-int(bin(x)[bin(x).rfind('1')-1])
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCylA3M69EIykzT6NCMxpC6RWlZealaKgbqmvqGsZq/i8oAilJ0zAyNDbT1PwPAA "Python 2 – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~11~~ 10 bytes
```
t4*YF1)Z.~
```
[Try it online!](https://tio.run/##y00syfn/v8REK9LNUDNKr@7/f1MA "MATL – Try It Online") Or see the [first 100 outputs](https://tio.run/##y00syflvaGBgpeTwv8REK9LNUDNKr@5/rFrGfwA).
### Explanation
```
t    % Implicit input. Duplicate
4*   % Multiply by 4. This ensures that the input is a multiple of 2, and
     % takes into account that bit positions are 1 based
YF   % Exponents of prime factorization
1)   % Get first exponent, which is that of factor 2
Z.   % Get bit of input at that (1-based) position
~    % Negate. Implicit display
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 20 bytes
```
n->kronecker(-1,n)>0
```
Using the [Kronecker symbol](https://en.wikipedia.org/wiki/Kronecker_symbol).
[Try it online!](https://tio.run/##DcjBCcAgDAXQVUJPBgyYAcwupWgR4Suh@6de3uHt24e8OzrVgNj0hfbM5kk0g61EX55AlTSTlpJp@8B35iKxQ09g5vgB "Pari/GP – Try It Online")
[Answer]
# SCALA, 99(78?) chars, 99(78?) bytes
```
if(i==0)print(1)else
print(if(('0'+i.toBinaryString).reverse.dropWhile(x=>x=='0')(1)=='1')0 else 1)
```
where `i` is the input.
As you can see, I do save 21 bytes if I don't take care of the zero (as the author did in his test case) :
```
print(if(('0'+i.toBinaryString).reverse.dropWhile(x=>x=='0')(1)=='1')0 else 1)
```
This is my first codegolf so I hope I did well :)
[Try it online!](https://tio.run/##TY4xb8IwEIVn/CtOWeJTRGQXiQHVSLAxdOrQpYtJLuAqOkeOQalQf3t6iKpiu7v33XtvbHzv53j8oibDmw8MNGXidoTdMNzUoqUO2uRPkZtLupIOmwNnvM2h08E5g0MKnLVF6kdSj0UkXZqyCnWO@8A@fb9nEU5YJ7pSGqluUxw@zqEnPbnt5JzQKB4y2BIN3L3A4vyjVBeTZnhdgoEcwRqD0ukRU3xyUXFVwHILBUrTp5aMSp7/uRe7Wv9hz9T9LOD8Cw) Though it's quite long to compute lol.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~35~~ 31 bytes
```
f(x){return~x&1?f(x/2):!(x&2);}
```
Switched to a recursive implementation.
[Try it online!](https://tio.run/##FclBCoMwEEbhfU7xK1RmsKXGpan0LCVtZBZNJUQISHr1GJfvffa2WFuKo8R7@MQt@H/q9LP2feSpodSNbHIRH/F9iSfeFeB@gc4jszbymPUwGOl7ME4E1lDRUXt5o73CkTDYVMkqq3IA "C (gcc) – Try It Online")
[Answer]
# Java 8, 17 bytes
```
n->(n&2*(n&-n))<1
```
Straightforward port of [LeakyNun's Python 3 answer](https://codegolf.stackexchange.com/a/128877/58251). I'm not familiar enough with bitwise operations and operator precedence to see a shorter solution; maybe there's a way to avoid the extra parentehesis?
[Answer]
# [Chip](https://github.com/Phlarx/chip), 93 bytes
```
HZABCDEFG,t
 ))))))))^~S
H\\\\\\\/v~a
G\\\\\\/v'
F\\\\\/v'
E\\\\/v'
D\\\/v'
C\\/v'
B\/v'
A/-'
```
Takes input as little endian bytes. (The TIO has a bit of python that does this for you). Gives output as either `0x0` or `0x1`. (The TIO uses xxd to inspect the value).
[Try it online!](https://tio.run/##TVDLasMwELzrK5ZcZNFEog20gTwgDzu59dBbKQ1@KLHAlYS0aW0I@XVXTpzSOczM7sLOslnqyzZPERZgnTnyvFQWZjOg8WtC2937crXexMl2iARYj8/LG9l93CC@LynZ3j0lyZ@L72bT6/omqysvxYi2IYKQLpsrbU/IURk4g22wNHoMoxwG6ssah@AbP4Ua5qA0RqHgHguluZNpETE2hb5lwo7sdDhIx3@cQhnVHM0@a1D6KPhM4b6S@ohlxB5emBCTIXRD4wrp5rRSiJWkjA3CEcJYFN0vrsRt8@87Z6jron16HD//Ag "Chip – Try It Online")
### How do it this?
Chip looks at input one byte at a time, so handling multibyte input adds some bulk, but not near as much as I had feared.
Let's go into it:
```
HZABCDEFG
```
These are `HZ`, high bit of the previous byte (if there was one), and `A`-`G`, the seven lower bits of the current byte. These are used to locate the lowest set bit of the number.
```
        ,t
))))))))^~S
```
When the lowest set bit is found, we have a few things to do. This first chunk says "if we have a set bit (the `)`'s), then stop `S`uppressing the output, and `t`erminate after we print the answer.
```
H\\\\\\\/v~a
G\\\\\\/v'
...
A/-'
```
Whichever bit of the current byte (`A`-`H`) is only preceded by a bunch of zeroes then a one (`\` and `/`: these look at the bits directly north of them; we can trust that all previous bits were zero) is passed through to the wires on the right (`v`, `'`, ...), then whichever value it is is inverted and given as the low bit of output (`~a`).
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 12 bytes
```
1≠¯1⊥2↑⍸∘⌽∘⊤
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/3/BR54JD6w0fdS01etQ28VHvjkcdMx717AWRXUv@pz1qm/Cot@9RV/Oh9cYg@b6pwUHOQDLEwzP4fxlItm8ql6GCoYKBAoSE0DAWMh8makBAHl2/AYX6CdkPN5/rUdeicqCX0g6teNS72dDAgKvsUefCcgA "APL (Dyalog Extended) – Try It Online")
Took the idea of using `⍸` from [Razetime's answer](https://codegolf.stackexchange.com/a/211228/78410).
### How it works
```
1≠¯1⊥2↑⍸∘⌽∘⊤  ⍝ Input: n
           ⊤  ⍝ Binary representation of n
         ⌽∘   ⍝ Reverse
       ⍸∘     ⍝ Get indices of ones, in increasing order
              ⍝   LSB index (l) comes first, and the next number is l+1
              ⍝   iff the bit on the left of LSB is also 1
     2↑       ⍝ Take first two numbers, filling with 0 if too short
  ¯1⊥         ⍝ From [a, b] compute -a + b
1≠            ⍝ Is it not equal to 1?
```
Equivalent non-extended program:
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 17 bytes
```
1≠¯1⊥2↑∘⍸∘⌽2∘⊥⍣¯1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3/BR54JD6w0fdS01etQ28VHHjEe9O0Bkz14jENW19FHvYqD8/7RHbRMe9fY96mo@tN4YpLJvanCQM5AM8fAM/l8Gku2bymWoYKhgoAAhITSMhcyHiRoQkEfXb0ChfkL2w83netS1qBzopbRDKx71bjY0MOAqe9S5sBwA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 12 bytes
```
~1=-/|-2#&2\
```
Modeled after [@Bubbler's APL answer](https://codegolf.stackexchange.com/a/211251/98547).
* `2\` convert input to base-2
* `-2#&` get the last two indices containing 1's
* `-/|` subtract the smaller index from the larger one
* `~1=` if the last truthy index isn't preceded by another truthy value, return 0. otherwise, return 1
[Try it online!](https://tio.run/##y9bNS8/7/z/Nqs7QVle/RtdIWc0o5n@RlaGCoYKBAoSE0DAWMh8makBAHl2/AYX6CdkPN5@rqC5N3VBb0dDA4D8A "K (ngn/k) – Try It Online")
]