[Question]
  [
Congratulations to [Neil](https://codegolf.stackexchange.com/users/17602/neil) for hitting 100k rep! As a tribute, we are going to study 'Neil numbers'.
Neil's user ID is **[17602](https://codegolf.stackexchange.com/users/17602/neil)** and there's something special about the binary representation of this number:
$$17602\_{10}=1\color{blue}{000}1\color{blue}{00}11\color{blue}{0000}1\color{blue}{0}\_2$$
$$\begin{array}{c|c}
1&\color{blue}{000}&1&\color{blue}{00}&11&\color{blue}{0000}&1&\color{blue}{0}\\
\hline
&3&&2&&4&&1
\end{array}$$
There's exactly one group of consecutive zeros of length **1**, one group of length **2**, one group of length **3** and one group of length **4**.
This is an order-4 Neil number.
More generally:
> 
> An order-\$n\$ Neil number is a positive integer whose binary
>  representation contains exactly \$n\$ groups of consecutive zeros and
>  for which there's exactly one group of consecutive zeros of length
>  \$k\$ for each \$0<k\le n\$, with \$n>0\$.
> 
> 
> 
Clarifications:
* Leading zeros are obviously ignored.
* Groups of consecutive zeros are indivisible (e.g. `000` is a group of length 3 and cannot be seen as a group of length 1 followed by a group of length 2, or the other way around).
## Examples
Order-1 Neil numbers are [A030130](https://oeis.org/A030130) (except **0**, which is not a Neil number as per our definition).
The first few order-2 Neil numbers are:
```
18, 20, 37, 38, 41, 44, 50, 52, 75, 77, 78, 83, 89, 92, 101, 102, 105, 108, 114, ...
```
## Your task
Given a positive integer as input, return \$n\ge 1\$ if this is an order-\$n\$ Neil number or another consistent and non-ambiguous value (*0*, *-1*, *false*, *"foo"*, etc.) if this is not a Neil number at all.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
## Test cases
Using **0** for non-Neil numbers:
```
Input   Output
1       0
2       1
8       0
72      0
84      0
163     0
420     0
495     1
600     3
999     0
1001    2
4095    0
8466    4
16382   1
17602   4
532770  5
```
Or as lists:
```
Input : 1, 2, 8, 72, 84, 163, 420, 495, 600, 999, 1001, 4095, 8466, 16382, 17602, 532770
Output: 0, 1, 0, 0, 0, 0, 0, 1, 3, 0, 2, 0, 4, 1, 4, 5
```
Brownie points if your user ID is a Neil number. :-)
  
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 21 bytes
```
≔Φ⪪⍘Ｎ²1ιθＩ×Ｌθ⬤θ№θ×0⊕κ
```
[Try it online!](https://tio.run/##JYrBCoMwEETv/QrJaYUU1EN78GSFglBKwf5Ami4xGKMmm/5@uuDAGwbm6UkFvSqXcxejNR7u1hEGGDdnCW4q4kjBegOD3xI90/Lhs5RFw4hacFtmL9vTizWCXkWCt10wwgO9oQl2/jvnYJdFvyZWeByCqIQsBq8DLugJvzCXR9qc6@ulavL55/4 "Charcoal – Try It Online") Link is to verbose version of code. Outputs `0` for irrelevant numbers. Happens to output `1` for `0` as per the OEIS sequence. Explanation:
```
≔Φ⪪⍘Ｎ²1ιθ
```
Convert the input to binary, split on `1`s, and remove empty elements.
```
Ｉ×Ｌθ⬤θ№θ×0⊕κ
```
Check that the array contains all lengths of `0`s and output its length if it does or `0` if it does not.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~88~~ 86 bytes
*-2 bytes thanks to @David!*
```
s=sorted([0]+map(len,bin(input()).split("1")[1:]))
n=s[-1]
print(s[~n:]==range(n+1))*n
```
[Try it online!](https://tio.run/##TVDLasMwELzrKxafpEYtkt82@EuMDk6sNgJnLSwF2h766@5aTUtBzD60M8us/4jXFfP9ss4WBsiybA9DWLdoZz4qc7pNni8W5dkhd@jvkQvxEvziIs90JkbdGyEYDmF81ob5zWHkYfzC3gzDNuGb5XjSQjzhTtKMJYlAi0YtIZfQSmgo6LqQUOaKoKsk1IqyruvoQykaLNXRbcu6TqPtwWhqRaEq8qZRhq33@CtMVKKof4/KIiV5wjJ1CCvD2Ou6AUqw795eyDM4hE/nf6wGCQ9d0TNILVqwTLfzPPXIiGQvcByOQTL@p/Ko6Zbf "Python 2 – Try It Online")
Finds the length of all zero groups, sorts them, and check if the sorted list is `1, 2, 3, ...`
---
Same idea in Python 3.8:
### [Python 3.8](https://docs.python.org/3.8/), ~~85~~ 82 bytes
```
lambda n:(m:=max(s:=sorted(map(len,f"{n:b}".split("1")))))*(s[~m:]==[*range(m+1)])
```
[Try it online!](https://tio.run/##TU/bboQgEH33KyY@4ZY0eEMl5UusD25XWxNBAphsa@yv29GtTQk5c5iZc4Yxn/5j0mlp7NbL121s1fXWghZECanaO3FCusn67kZUa8jYadqHixbXNXx2Zhw8CeMw2s@FuPpbiUbK@mJb/d4R9RRHTbQN2szegYQ6ppBQKCkUGGKeUsgShlDlFDhDVlUVFhjDxozt2TLj/Ggtd0XBGYY8TYqCNcE0@9MYpShh/y4@04MkB2ZHBjFvgqCfLGgK3d10b7gYDBq@BkMe/6Tw6xuJAGzn5tHjhJ7oKABjB@3Jsf8LX2F5lJGcVivUy6mRfwPWJoy2Hw "Python 3.8 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~16~~ ~~15~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
b1¡€gZ©L¢PΘ®*
```
Outputs `0` as falsey result.
[Try it online](https://tio.run/##ASEA3v9vc2FiaWX//2IxwqHigqxnWsKpTMKiUM6Ywq4q//82MDA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/JMNDCx81rUmPOrTS59CigHMzDq3T@q/zP9pQx0jHQsfcSMfQzFjHxMhAx8TSVMfMwEDH0tJSx9DAwFDHxAAoYmFiZgZSYgFUaG5mACQtDUyMdUyNjczNDWIB).
**Explanation:**
```
b              # Convert the (implicit) input to a binary-string
               #  i.e. 163 → "10100011"
               #  i.e. 420 → "110100100"
               #  i.e. 600 → "1001011000"
 1¡            # Split it on 1s
               #  → ["","0","000","",""]
               #  → ["","","0","00","00"]
               #  → ["","00","0","","000"]
   €g          # Take the length of each chunk
               #  → [0,1,3,0,0]
               #  → [0,0,1,2,2]
               #  → [0,2,1,0,3]
     Z         # Get the maximum (without popping)
               #  → 3
               #  → 2
               #  → 3
      ©        # Store it in variable `®` (without popping)
       L       # Pop an push a list in the range [1,maximum]
               #  → [1,2,3]
               #  → [1,2]
               #  → [1,2,3]
        ¢      # Get the count of each in the list of chunk-lengths
               #  → [0,1,3,0,0] and [1,2,3] → [1,0,1]
               #  → [0,0,1,2,2] and [1,2] → [1,2]
               #  → [0,2,1,0,3] and [1,2,3] → [1,1,1]
         P     # Get the product of that
          Θ    # And check that it's exactly 1
               #  → 0 ==1 → 0 (falsey)
               #  → 2 ==1 → 0 (falsey)
               #  → 1 ==1 → 1 (truthy)
           ®*  # Multiply it by the maximum we stored in variable `®`
               #  → 0*3 → 0
               #  → 0*2 → 0
               #  → 1*3 → 3
               # (after which the result is output implicitly)
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 17 bytes
Anonymous tacit prefix function. Any visual similarity with OP is entirely unintentional.
```
(≢×⍳⍤≢≡∘∧≢¨)~⍤⊤⊆⊤
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X@NR56LD0x/1bn7UuwTIfNS58FHHjEcdy4HsQys060CiXUDUBiT/pz1qm/Cot@9RV/Oj3jWPerccWm/8qG3io76pwUHOQDLEwzP4f5qCoQIYPOqdq2DAlaZghOAaArkWqLLmRihcQzNjZK6JkQEK19IU2SgzA7isMZBraWmJYpSBgSGUawTSawDWDJO1MDEzg3JNIPZaGCFMNjQ3MzBCyJoaG5mbG4C5pgA "APL (Dyalog Extended) – Try It Online")
The structure and order of execution is as follows:
```
  ┌────────┴───────┐  
┌─┼──────┐      ┌──┼──┐
≢ ×  ┌───┼───┐ ~⍤⊤ ⊆  ⊤
    ⍳⍤≢ ≡∘∧ ≢¨
7 8  5   6   4  2  3  1
```
`⊤` base-Two representation
`⊆` extract sub-lists according to the runs of 1s in…
`~⍤⊤` negated (0→1, 1→0) base-Two representation
`(`…`)` apply the following function to that:
 `≢¨` the length of each run
 `≡∘∧` when sorted, does it (0/1) match…
 `⍳⍤≢` the indices of the length?
`×` multiply that by…
`≢` the length
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 54 bytes
```
.+
$*
+`(1+)\1
$1O
(O?1)+
1
O`O+
(^1O|\1O)+1?$|.+
$1
O
```
[Try it online!](https://tio.run/##Fco7DsIwEEXR/q3DSDYjoXmO40@VknI2ECFTUNBQIMrs3Tjtvef7@r0/z3Hx9z5uAneFdE8JO@Fo8LYxCAjrJvAP2rHTgnBzx8nnGIOIqCgRzAtSVKS2IquitQaqEklnqSnnk9QJS9aIdYml6B8 "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
.+
$*
```
Convert to unary.
```
+`(1+)\1
$1O
```
Begin base 2 conversion, but using `O` instead of `0` as `\10` would be an octal escape.
```
(O?1)+
1
```
As part of base 2 conversion we need to remove one `O` before each `1`. This additionally also collapses all runs of `1`s into a single `1`, which simplifies matching the consecutive runs of `O`s later.
```
O`O+
```
Sort the runs of `O`s in ascending order of length.
```
(^1O|\1O)+1?$|.+
$1
```
Try to match `1O`, then in each repeat match one more `O` than last time, finally matching an optional `1` at the end. If this succeeds, output the last match (including the leading `1`), otherwise output nothing.
```
O
```
Count the `O`s in the last match.
[Answer]
# [J](http://jsoftware.com/), 30 24 bytes
```
0(#*/:~-:#\)@-.~#;._1@#:
```
[Try it online!](https://tio.run/##PY6xCoMwEIb3e4ojDmpb00vURFMEodCpU9dWShGldOlgt4KvbqOJPQh8fLn/514T42GPlcEQd0ho7Es4Hi/n00RRsNmbMTHBLa4TPgYHfhd1YKYY4NM@hm7AimPEuPUynsMEAt0QSE8Cir/TciWhUk@ZpJXK3CcUOZdCWZZrgmgpl5CRWyQoMqVmyua@Qi5ZoRXJxeWp1NoW5WAP7trnG3u2xS9nokF3v7NRX1@xwibeM@E/ph8 "J – Try It Online")
*-6 bytes thanks to Bubbler*
Fittingly, J has been bested here by Neil's Charcoal answer.
[Answer]
# [Zsh](https://www.zsh.org/), 76 bytes
```
for g (${(s[1])$(([#2]$1))#??})((a[$#g]++))
<<<${${${${a/#%/0}:#1}:+0}:-$#a}
```
[Try it online!](https://tio.run/##JYzLCoMwEEX3fsVARpxBiklsFULAD0mzEGxsN7YYV5V8e/qQuzhnc@473nMgphyeK8xAuFN0yjMSOaE9KmYxDImJRodi9nXNXFhrcT82NqJsZDJCJVN/eUIxpszF7267xQ1IgYYWztBJCarvpIZLq/teMrzWx7IFqEolJ1Pq6bpUgP8IKRzG@QM "Zsh – Try It Online")
Explanation:
```
${(s[1])$(([#2]$1))#??}
```
Convert to binary, remove the `2#` prefix, and split the string on `1`, giving us our groups of zeroes.
```
for g ( ... )((a[$#g]++))
```
For each group of zeroes, increment the array at the index given by the length of that string.
```
${a/#%/0}
```
Substitute the array with empty elements filled with zeroes. (If we only increment the array at `a[3]`, then this will set `a[1]=a[2]=0`)
```
${${${${ ... }:#1}:+0}:-$#a}
```
Remove all `1`s. If there is anything left (some a[n] != 1), then substitute 0. Otherwise (all a[n] = 1) substitute the length of the array.
[Answer]
# [R](https://www.r-project.org/), ~~94~~ ~~85~~ ~~75~~ 74 bytes
```
n=scan();z=rle(n%/%2^(0:log2(n))%%2);N=max(0,s<-z$l[!z$v]);N*all(1:N%in%s)
```
[Try it online!](https://tio.run/##K/r/P8@2ODkxT0PTusq2KCdVI09VX9UoTsPAKic/3UgjT1NTVdVI09rPNjexQsNAp9hGt0olJ1qxSqUsFiiqlZiTo2Fo5aeamadarPnf8D8A "R – Try It Online")
*Edit: -10 bytes thanks to Giuseppe*
*Edit 2: -1 more byte thanks again to Giuseppe*
Finds differences (`diff`) between remainders of each power-of-two (`n%%2^(0:(l=log2(n))`); when sequential remainders are the same, this corresponds to a run of 'zero bits'. `rle` calculates run lengths, and `s` extracts runs of zeros. If `s` contains all the integers up to it's length `N`, then it's a 'Neil number'. 
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
BŒɠḊm2ṢJƑȧ$Ṫ
```
A monadic Link accepting a positive integer which yields the order (or `0` if not a Neil number).
**[Try it online!](https://tio.run/##ASUA2v9qZWxsef//QsWSyaDhuIptMuG5okrGkcinJOG5qv///zE3NjAy "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8/9/p6KSTCx7u6Mo1erhzkdexiSeWqzzcuer/4fZHTWv@/zfUUTDSUbDQUTAHUSY6CoZmxjoKJkYGQMLSVEfBzADIsrS0BEoYGAAVmxiARC1MzMzASi2AugzNzQyAlKmxkbm5AQA "Jelly – Try It Online").
### How?
```
BŒɠḊm2ṢJƑȧ$Ṫ - Link: positive integer, V       e.g. 600
B            - convert V to binary                  [1,0,0,1,0,1,1,0,0,0]
 Œɠ          - run lengths of equal elements        [1,2,1,1,2,3]
   Ḋ         - dequeue                              [2,1,1,2,3]
    m2       - modulo-two slice                     [2,1,3]
      Ṣ      - sort                                 [1,2,3]
          $  - last to links as a monad:
        Ƒ    -   is invariant under?:               1
       J     -     range of length                  (since range(len([1,2,3]))==[1,2,3])
         ȧ   -   logical AND                        [1,2,3]
           Ṫ - tail (if empty yields 0)             3
```
---
Alternative start: `Bṣ1Ẉḟ0ṢJƑȧ$Ṫ`
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~116~~ \$\cdots\$ ~~78~~ 77 bytes
Saved ~~8~~ 11 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!  
Had to fix a bug, for numbers like \$84\$ (\$1010100\_{2}\$) which have multiple runs of single \$0\$s, which added 3 bytes.  
Saved 14 bytes thanks to a suggestion from the man himself [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)!!!  
Added 6 bytes to fix bugs for numbers with multiple runs of zeros of the same length. 
```
c;b;f(n){for(c=3;n;n/=b,c=c&b&~3?n=0:c|b)b=1<<ffs(n);n=ffs(++c)-3;n*=c<8<<n;}
```
[Try it online!](https://tio.run/##TVBNb4MwDL33V1hIrUgJaviGhWyHab@i9FBS2HJYWhEO1Rj768xQQI3Is43fsx1L91PKYZC85LWtSVdfG1uKgGuuD6KkUshdufsL3rRgL/K3JKXw8ryuDXK5FqPjOJK4KNgLmad5rnk/fJ@Vtgl0G8CjdAttZVpzPIEA6DwKPoWUQjKakIIXBxRCnyFkEYWYoZdlGSYYQ3LIxr9pGMcTNUWVl8QMTRT4ScJ6vrap7rdKtlOfDougmE3feh/gjRCsoT/Cw4VwwomwBBDNHeTXudlD8yhvFfcPv7hn73gji8JzHFizApcJ9jiYQgnjaHIw6qe61va0EXKYI@QQDo6jlqUtLzIonMlHdSJ8Td4aTNe2tXXjC7ivsL3A1hQaJ1nIFAzFaeedqJMQZinQb/rhHw "C (gcc) – Try It Online")
Returns \$n\$ for an input of an order-\$n\$ Neil number or \$0\$ otherwise.
**How?** 
Performs a bit-wise logical-or summation \$c=3+\sum{2^{r+1}}\$, where \$r\$ is the length of a zero bit run for all runs in the input number (including zero length runs). Checks to see if we've seen the same non-zero length run before and returns \$0\$ if we have. After all the input's zero-bit runs have been added to \$c\$ in this manner, \$c\$ is tested to see if we've seen \$n\$ zero-bit runs of lengths \$(1,2,\dots,n)\$ by testing if \$c\stackrel{?}{=}2^{n+2}-1\$ and returns \$n\$ if this is true, \$0\$ otherwise.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 13 bytes
```
ḃḅ{h0&l}ˢo~⟦₁
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRuX/2obcOjpma9Rx0rlNISc4pT9ZRqH@7qrH24dcL/hzuaH@5orc4wUMupPb0ov@7R/GWPmhr//4821DHSsdAxBxImOoZmxjomRgY6JpamOmYGBjqWlpY6hgYGhjomBkARCxMzM5ASCyMdQ3MzAyMdU2Mjc3ODWAA "Brachylog – Try It Online")
```
 ḅ               Take the runs of
ḃ                the input's binary digits,
  {h0  }ˢ        keep only those that start with 0,
  {  &l}ˢ        and map them to their lengths.
         o       The sorted run lengths
          ~⟦₁    are the range from 1 to the output.
```
Fun fact, my original attempt was `ḃḅo{h0&l}ˢ~⟦₁`, but it mysteriously created a choice point giving me some false positives, so I moved the `o` later to save on a `!`.
[Answer]
# [Haskell](https://www.haskell.org/), 113 bytes
```
g.f
f 0=[0]
f x|h:t<-f$div x 2=[0|odd x]++(h+1-mod x 2):t
g x|n<-maximum x,r<-[1..n]=sum[n|r==[k|k<-r,y<-x,k==y]]
```
[Try it online!](https://tio.run/##HYvBjoMgEEDv/Yo59LCNYAZrURv4EpYDqasYhRq1G5r47WVxL/Mmb95Ys44/0xSt/I593p06QKlQJ4bd3jdBu3M7/EKAIun92bYQdJZ92YxR92wPf7lvpz7VXlBnwuBeDgJZBFUsz72W68spvy9SqnEfBV3IW9BARinfWkdnBg8S5mXwG5zBmRksKEagIFATqA6UBBi/EigLTKO5EeCYtqZp0gExxSUeti45/0/r9MUqjgm3a1FVqOPn0U2mXyN9zPMf "Haskell – Try It Online")
[Answer]
# [COW](https://bigzaphod.github.io/COW/), 234 bytes
```
oomMMMMOOOOOmoOMMMMOOMOomoOMoOmOoMMMMOOMMMMOomoOMOomOomOoMoOmoOMMMOOOmooMMMmoomoOmoOMoOmOoMOOmoOMOoMOOMMMmoOmoOMMMMOomoomoOMoOmOoMoOMOOmOomOomoomoOmoOOOOmOoOOOmoomOomOoMMMmoomoOmoOmoOmoOmoOMOOMMMMoOMMMmoOMOoMOOOOOMMMmOomoomoOmooMMMOOM
```
[Try it online!](https://tio.run/##TY9LDsMgDET3nIIjgEMgHKGLyIfomrqLRD0@xR9oLWSNhvEzPOnTH6/3fXnv8b6GcNFrBQemojuWV2CqI00V82YqQZiq7jabg3qbq7XOiRBkDbgUNMi8nFkl5h0gs7HkAOLtG5QyQHsnauco5GqEqk8k1oQNyRzuYo4uh28lL4McG72pqYMKFCG3i0@atBhnUJmLgOIo2db98dexh5HxdRfquh@N9Ae9fwE "COW – Try It Online")
Forms a "string" \$S\$ where:
\$k\in \{1,\dots,n\}\$
* *Even indexes* (or `control cells`) \$2k-2\$ serve:
	+ to navigate \$S\$
	+ to know where \$S\$ ends
	+ to count up to \$n\$
* *Odd indexes* (or `k-cells`) \$2k-1\$ contain how many consecutive \$k\$ zeros there are
The idea is: when a group of consecutive \$k\$ zeros is found, its `k-cells` in \$S\$ is incremented.  
Hence the input is a order-\$n\$ Neil number if and only if all `k-cells` are \$1\$.  
If so, their quantity \$n\$ will be returned.  
`0` is returned otherwise.
## Explanation
```
moo ]    mOo <    MOo -    OOO *    OOM i
MOO [    moO >    MoO +    MMM =    oom o
[0]: a/2     [1]: a     [2]: a%2     [3]: counter of current group of 0 (k)     [4]: // unused stuff    [5]: S(0)
i=                               ;   Read a in [0], copy
[                                ;   While [0]
    *>=                          ;      Clear [0], paste in [1]
    [                            ;      While [1]
        ->+<=[=->-<<+>=*]=       ;          {REPEATED SUBTRACTION}
    ]                            ;      [0] is a/2, [1] is 0, [2] is a%2
    >>+<                         ;      Increment [3]                                                   // here [3] is k+1
    [                            ;      If [2] {UPDATE THE STRING}                                      // if a%2==1 the current group of 0 it's been truncated
        >-                       ;          Decrement [3]                                                   // [3]-=1 (k)
        [=>>=-]                  ;          While [x] copy it in [x+2] and decrement it                     // moves to control cell 2k-2 and leaves a trail of control cells behind
        >+<                      ;          Increment [x+3]                                                 // k-cell 2k-1 +=1
        +[<<]                    ;          "Open" [x+2], while [x] x-=2                                    // use the trail to return back to [1]
        >>*<*                    ;          Clear [2] and [3]
    ]                            ;      
    <<=                          ;   Point to [0], copy
]                                ;
>>>>>                            ;      Point to [5]                                                    // the first control cell in S
[                                ;      While [x] is non-zero                                           // while S has not ended
    =+=                          ;          Paste, increment [x], copy                                  // counting (n)
    >-                           ;          Move to [x+1] and decrement                                     // k-cell-=1
    [                            ;          {NOT A NEIL NUMBER}                                             // iff k-cell is non-zero
        *=<                      ;              Divert the flow (performs this loop 2 times, copy 0)
    ]                            ;              will now break the parent while|
    >                            ;      Point to [x+2]                         |                        // next control cell
]                                ;                                             |
=o                               ;   Paste (n or 0) and print                  v
```
*Cell `[4]` contains the number of groups of consecutive ones that are larger than \$1\$, +1 if LSB is 1*.  
Nothing relevant for the task, but I couldn't get rid of it staying in this byte count.  
Here's a [var dump from [4]](https://tio.run/##TU1BDoAwDPqKTzAas1c0fYTnhqPPryvUxaYhjAK78WQCYXO8JuDi5igOD0crhRQncutKP4NlmxgSFVQhCa@rH3K2rTyuztXgVNTc3/3611rbjBH7dOiZeZ3HGPu2vQ "COW – Try It Online").
[Answer]
# [Java (JDK)](http://jdk.java.net/), ~~126~~ ~~117~~ 116 bytes
* Saved 1 byte thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)
* Saved 6 bytes - 9, really - thanks to [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)
```
q->{int C[]=new int[9],s=0,n=0;for(;q>0;q/=2)C[s]-=q%2<1?(n=++s>n?s:n)-n:~(s=0);while(q++<n)n=C[q]!=1?0:n;return n;}
```
[Try it online!](https://tio.run/##ZZBNb6MwEEDv/hWzlSpBMcQQwkeIySHSSj301CPiQFOSdZY6gE2rKkr/ejq4sJflMPM0zNjzfKreK/f0@vfWDi@N2MO@qZSCp0pIuBCAqap0pTGdsNkbtGi8wyD3Wpyl93uCzaPU9bHuKUyQwwH4rXPzi5AadkXJZf0ByEVaUsUZlZxlh3NvZV3Osm7BA3tXqNLl3X2w8beW5I6jcrlVa2m7cv1l4YydffwRTW11jrORtuS7oit/cX/L1jLraz30EmR2vWX/Lf5@Fq/whlLWs@6FPBYlVP1R2cYRzFYlxnbQCjhcfAoBhYRCPKaQgh8tKYQBw5CuKEQMKU1T/MEYNodsrCZhFJnWBKf8OGKYVssgjtk1M9egLVjjawhYT7fZ8PypdP3mnQfttbiabqQlwIE7cHMMDhy8qm2bT0vY9njKlVzJ4oH48PMxEkzkk@RfLQ5mSsKZcK@J0GOmdDXNopGhJUGteQLdRgrI6DefF0UjhcR4mlmjamo/tgAr8rC4fQM "Java (JDK) – Try It Online")
Returns 0 for non-Neil numbers.
I feel like this should be smaller, even though it is in Java.
Ungolfed:
```
q -> {
  int C[] = new int[9],  //C[i] is how many times a streak of length i appeared
      s = 0,             //Length of current streak of zeroes
      n = 0;             //Max streak
  for(; q > 0; q /= 2)   //Go through all of q's digits until q=0
    C[s] -= q % 2 < 1                //If there's a 0 here
            ? (n = ++s > n ? s : n)//Increment s and set n to the max of s and n
               - n      //Subtract n from that because C[s] should stay the same
            : ~(s = 0);  //Otherwise, set s to 0 and add 1 to C[s] (the previous value of s)
  while(q++ < n)           //For every q 0 < q <= n
    n = C[q] != 1 ? 0 : n; //if there was not exactly 1 group of length q, set n to 0
  return n;
}
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 14 bytes
```
BY'w~)SttfX=*z
```
For non Neil numbers the output is `0`.
[Try it online!](https://tio.run/##y00syfn/3ylSvbxOM7ikJC3CVqvq/39TYyNzcwMA) Or [verify all test cases](https://tio.run/##y00syfmfFark8N8pUr28TjO4pCQtwlar6r/Lf0MdBSMdBQsdBXMgZWhmrKNgYmQAJCxNdRTMDIAsS0tLoISBAVChiQFI1MLEzAys1AKkw9zMAEiZGhuZmxsAAA).
### Explanation
Consider input `532770` as an example.
```
B     % Impicit input. Convert to binary
      % STACK: [1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0]
Y'    % Run-length encoding. Gives values and run lengths
      % STACK: [1 0 1 0 1 0 1 0 1 0], [1 5 1 4 1 2 1 3 1 1]
w~    % Swap, negate element-wise
      % STACK: [1 5 1 4 1 2 1 3 1 1], [0 1 0 1 0 1 0 1 0 1]
)     % Indexing (use second input as a mask into the first)
      % STACK: [5 4 2 3 1]
S     % Sort
      % STACK: [1 2 3 4 5]
tt    % Duplicate twice
      % STACK: [1 2 3 4 5], [1 2 3 4 5], [1 2 3 4 5]
f     % Find: (1-based) indices of nonzeros
      % STACK: [1 2 3 4 5], [1 2 3 4 5], [1 2 3 4 5]
X=    % Equal (as arrays)?
      % STACK: [1 2 3 4 5], 1
*     % Multiply, element-wise
      % STACK: [1 2 3 4 5]
z     % Number of nonzeros. Implicit display
      % 5
```
[Answer]
# perl -MList::Util=max -MList::Util=uniq -pl, 72 71 bytes
```
@==map{y===c}sprintf("%b",$_)=~/0+/g;$_=(@===max@=)&(@===uniq@=)?0+@=:0
```
[Try it online!](https://tio.run/##VY7BCoJAFEX37zPEQjHxOY6jYzzyA2rZWioqBkwnnaCI@vSmyV27ew8H7tXHoc2trYkuO/18ENHhNepBdeYUeLO9t/CbkN4JRsl56TcUONGZ95rC@ZRvnbq6ssKopgqtTYFBCQWDVGTAGQKXOQhEkFJCipgCR0dKLsRPKZ1YCGSQZ6wo8NNro/putPFmrUZTVVuj2mnjn7gHNtbtFw "Perl 5 – Try It Online")
Reads a number from the input, convert it to a string with the number in binary format, extracts the sequences of 0, takes their length, then prints the number of sequences of 0s if 1) there are no duplicates, and 2) the max length equals the number of sequences. Else, 0 is printed.
Edit: Saved a byte by replace `&&` with `&` which works, since the result of `==` is `1` or the empty string, which perl treats as `0` if the operator expects a number.
[Answer]
# [Python 2](https://docs.python.org/2/), 90 bytes
```
a=[len(z)-1for z in sorted(bin(input())[2:].split('1'))if z]
n=len(a)
print(range(n)==a)*n
```
[Try it online!](https://tio.run/##HY3BCoMwEAXv@xXBi0mhZRM10UK@RDxYjW1ANhJTaP15q70OM@8t3/QKpPYhjI5ZlmXZ3tt2dsQ3cZVTiGxjntgaYnIjf3jinpZ34kK06t7d1mX2iecyF8JPbOuA7Nn2ApboKfHY09NxEtb24kL7MQ/u4wb2v7swWe0SFNRgFEhdQKkQyqYCjQhN04BElFDiQepS61OpD9FoVFAVyhj8AQ "Python 2 – Try It Online")
I found almost the same solution as Surculose Sputum.
They had the further insight to get rid of the `[]` so go upvote them :)
[Answer]
# [Perl 5](https://www.perl.org/) `-pl`, 61 bytes
```
$a=1;$_=sprintf'%b',$_;$a++while s/10{$a}(?!0)//;$_=!/0/*--$a
```
[Try it online!](https://tio.run/##PY3tCoIwGIX/7yoUFlYmezf3iUiXIguMBNGhQj@iW281db2/Hg7nPK9rp154j21NK9zUs5u6Yblnh1t2wU2FbZ4/H13fJjOh8ML2fbymcCIkdFMC5FwU2HpPk@0AsZ0o0v9MsUiaR6Ky3IkziGTEvpWwZSUyxsQFwPqGIQ5bMfikDMSDT7N1S5UEtmaiZEr9RAJp@hnd0o3D7AvXfwE "Perl 5 – Try It Online")
Converts number to binary, then removes the 0 sequences in order, starting at 1. When it no longer finds a match, that's the Neil number.
[Answer]
# [Factor](https://factorcode.org/), 146 bytes
```
: f ( n -- n ) >bin [ = ] monotonic-split [ first 48 = ] [ length ] filter-map
natural-sort dup dup length [1,b] >array = [ last ] [ drop 0 ] if ;
```
[Try it online!](https://tio.run/##TY9NS8NAEIbv/RXvTQU3bNI0Hy32KgXpRTwVD9t20i6mm3V2Ahbxt8dNFPGwy8PMyzMzjTlIx8PL82b7uMQbsaMWFyPnxBsOxD/Mxp0owDCba0Cg957cgf5RQh/CJsxCx2LdCcG3VkZKLp3rpHP2AM8kcvVsnWA122yXeCK5CSpIf7yqLdlWuf6yJw7DEg1u4aBU/O6w3luHHR7wij@dmkbEamM5CPJqau/QkjvJOWJjWyFWF@NnzkjPplXjdjj2fnq/wV16v3/FejotKqLARN1oOnLnoSPaBqvhEykyVCgzpMUceaaR1wsUWqOua6Rap8h1rFR5UYyRKgbLQmdYzLOy1Pgadx0vMB7J8A0 "Factor – Try It Online")
Not golfy at all with all the mandatory spaces and those long words...
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 93 bytes
```
If[Sort[s=Length/@Take[Split@IntegerDigits[#,2],{2,-1,2}]]==Range@If[s=={},t=0,t=Max@s],t,0]&
```
[Try it online!](https://tio.run/##HYwxC4MwEIX/SqDQ6Ypn1KhDIEMXoYVSu0mGUNIYWm3RGwrib09jh7v3uPe9Gwz1djDk7yY4GZpH174n6mZ5sqOjPlE387Rd@3l5Us1I1tnp6J2nudsB17BwOKTAV62lvJrRWRU/zFIuK5DEOGfzVbMGAtT7cJn8SCxRLlFLCowDq4CVm@TAUpEByznGVRfABEZX13UMECOc43atciH@aBVbaSkwSpHxssQ1hB8 "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 118 bytes
```
n#0=[n]
n#i|mod i 2<1=(n+1)#div i 2|u<-0#div i 2=n:u
n%[]=n-1
n%x|1/=sum[1|a<-x,a==n]=0|m<-n+1=m%filter(>n)x
(1%).(0#)
```
[Try it online!](https://tio.run/##NcyxDsIgFEDRna9ogiQQRXkdamJ4/kjTgaRtJMLTtMUw8O9YB7d7lvtw63MKoVbiBnsaGHFf4mtsfNNaQElHUHz0n59Lstr8gXRLjEQ/IGnYIxe44JpiD8VZnU8OkQY0JVq9PzCK2YdtWuSdVGYzShDqLA1XNTpP@F48bYe5gWtn2voF "Haskell – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~67 58 57~~ 55 bytes
```
->n{i=0;('%b'%n).scan(/0+/).sort.all?{_1==?0*i+=1}?i:0}
```
[Try it online!](https://tio.run/##RY7LbsIwFET3fMUVCJmCm1w7ifNAJmrVXRf9gCiL8BJGKK54LFDsbw9GIGd37oxm5p5v63u/l/3nqu2UxOWMTNdk2n4El03TzkJchA71@Ro0p1PZmaM5SlniXC0ks6Uq0PbVCKBiFLCmT@IU2Isyr6XcYxZ7ZCLyHHMcOE98h0CnRy/O83zIIrpJ/g7gM@EHhKAQ@4lseIilArn3koinqWtP3FkHu2ZzgK0Goyho4/z/2/UC40mnbAGTbl@p2kLoSFswbwGkBA0lkL9fAgWQ768fYsejXbvtHw "Ruby – Try It Online") (+2 bytes because TIO doesn't support ruby 2.7's `_1`)
-2 bytes thanks to [Dingus](https://codegolf.stackexchange.com/users/92901/dingus)
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~14~~ 10 bytes
```
£ḣ∞0OfΛ¬gḋ
```
[Try it online!](https://tio.run/##AR8A4P9odXNr///Co@G4o@KInjBPZs6bwqxn4biL////NDk1 "Husk – Try It Online")
-4 bytes from Zgarb.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 15 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Returns `0` for falsey.
```
¤ôÍmÊÍf
Ê*UeUÊõ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=pPTNbcrNZgrKKlVlVcr1&input=MTc2MDI) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=pPTNbcrNZgrKKlVlVcr1&input=WzEsIDIsIDgsIDcyLCA4NCwgMTYzLCA0MjAsIDQ5NSwgNjAwLCA5OTksIDEwMDEsIDQwOTUsIDg0NjYsIDE2MzgyLCAxNzYwMiwgNTMyNzcwXQotbVM)
```
¤ôÍmÊÍf\nÊ*UeUÊõ     :Implicit input of integer                         > 17602
¤                    :To binary string                                  > "100010011000010"
 ô                   :Split at elements that return truthy
  Í                  :  When converted to decimal (0=falsey, 1=truthy)  > ["","000","00","","0000","0"]
   m                 :Map
    Ê                :  Length                                          > [0,3,2,0,4,1]
     Í               :Sort                                              > [0,0,1,2,3,4]
      f              :Filter, to remove 0s                              > [1,2,3,4]
       \n            :Assign to variable U
         Ê           :Length                                            > 4
          *          :Multiplied by
           Ue        :  Test U for equality with
             UÊ      :    Length of U                                   > 4
               õ     :    Range [1,length]                              > [1,2,3,4]
                     :Implicit output of result                         > 4
```
[Answer]
# [Io](http://iolanguage.org/), 124 bytes
Just a port of the 05AB1E answer.
```
method(x,i :=x asBinary lstrip("0")split("1")map(size);if(Range 1 to(i max)map(x,i select(o,o==x)size)reduce(*)==1,i max,0))
```
[Try it online!](https://tio.run/##HYw9bsMwDIX3nILwRBYcJMfxTwotPULnLoIjNwRky5BUwMnlXdkc@B75PlLCPsHdwM8@u/wMD9xYyryBTV@y2PgCn3KUFStVUVq9ZKx0RbNdMcnb0adM@G2XXwcackCB2W5nevxJzrsxY@BgzEYnH93jb3T4QcZoPmlWRLuXlFEz1Aw9Q3dIw6DbK0NTq9KGG0OrihuGoQRKFbhRx7Zv2vZE@3Klu1YVuV3rrlMEU4jOjk8UvkCpCYVgjbJkv1xo/wc "Io – Try It Online")
]