[Question]
  [
## Task
Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end).
## Rules
* There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - you may output anything that is not a positive integer for them (no need to be consistent).
* You choose whether to handle \$n=0\$.
* Standard [sequence](/questions/tagged/sequence "show questions tagged 'sequence'") [I/O rules](https://codegolf.stackexchange.com/tags/sequence/info).
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
## Test-cases
```
    n answer   (2^n)
    1     NA       2
    2     NA       4
    3     NA       8
    4      2      16
    5      2      32
    6     NA      64
    7      3     128
    8      2     256
    9      2     512
   10      4    1024
   11     NA    2048
   12      2    4096
   13      2    8192
   14      3   16384
   15      3   32768
   16      2   65536
   17      2  131072
   18      3  262144
   19      6  524288
   20      2 1048576
```
*Inspired by [this Mathematics SE post](https://math.stackexchange.com/a/4714518/347293) and comments on [OEIS A068994](https://oeis.org/A068994).*
  
[Answer]
# JavaScript (ES7), 35 bytes
Returns `NaN` if there's no odd digit. Supports \$n=0\$.
```
n=>(g=k=>k?k&1||1+g(k/10):+g)(2**n)
```
[Try it online!](https://tio.run/##FcZBDoIwEAXQPaf4KzNDFShLcfAsBGiDJTMGjBvx7DW@1XsM72Eft@X5uqhNcw6SVXqKkqRP93Tyx@FdpFT7hq8uMrVlqZyDbaQQNB0UN0H7j3OMTwGMprutc7VaJD0jkDJ3xTf/AA "JavaScript (Node.js) – Try It Online")
### Commented
```
n => (        // n = input
  g = k =>    // g = recursive function looking for an odd digit in k
  k ?         // if k is not zero:
    k & 1 ||  //   stop and return 1 if the least significant bit is set
    1 +       //   otherwise, increment the final result
    g(k / 10) //   and do a recursive call with k / 10
              //   note that we rely on arithmetic underflow to stop the
              //   recursion if the LSB is never set
  :           // else:
    +g        //   no odd digit found: return NaN, which will propagate
              //   all the way to the initial call
)(2 ** n)     // initial call to g with k = 2 ** n
```
---
# JavaScript (ES7), 30 bytes
A simpler version that throws an error if there's no odd digit.
```
n=>(g=k=>k&1||1+g(k/10))(2**n)
```
[Try it online!](https://tio.run/##PYxBDoIwFET3nGLCQvtpVGCL5S5NLaiQX/IhJgY4ey0bM5tJ3pt524@dnbym5cLh4WNnIptW9WYw7XCqtq3SvRpuVUmk6qJgil0QxTAoGzDuBvVRtCasGbDIFyvEz0noFFODHc4u7qk8/UHuRYLkiaWFCzyH0V/H0KdbjXOKPkRqsj3@AA "JavaScript (Node.js) – Try It Online")
[Answer]
# Excel, 50 bytes
```
=XMATCH(1,MOD(MID(2^A1,1+LEN(2^A1)-ROW(A:A),1),2))
```
Input in cell `A1`. Outputs an `#N/A` error if no odd digit exists.
*Edit: JvdV's wonderfully creative use of passing an array to `TEXTBEFORE` means that we can employ alternatives such as:*
```
=1+LEN(TEXTAFTER(2^A1,{1,3,5,7,9},-1))
```
*for just 38 bytes.*
[Answer]
# Ruby, 31 bytes
```
->n{(2**n).digits.index &:odd?}
```
0-indexed; no result returns `nil`.
I've been programming Ruby for about a year, and really enjoying it. As this example shows, it's possible to be concise and human readable.
`->n{ ... }` is the syntax for creating a lambda. It's not super elegant, but most of the time you're writing methods and not lambdas in Ruby anyways.
`.digits` already returns an array of digits starting with the least significant.
`.index` will search for an item if given an item, but it can also take a tester function, as it does here.
`.odd?` returns whether a number is odd. Prefacing a symbol with `&` creates a function that calls the method associated with that symbol. So `&:odd?` is equivalent to `->(number) { number.odd? }`.
[Answer]
# [Python 2](https://docs.python.org/2/), 41 bytes
```
f=lambda n,c=1:2**n/c%2or-~f(n,c%2**n*10)
```
[Try it online!](https://tio.run/##Rcq7DoIwGIbh/buKLoRDMPKXMwmbrl6AG2IJTbBtaj2weOsVJ5d3ePKa1c1ace@nfhlul@vAVDr21PEkUfsx4NruPlO0WfCThLLYv2a5CEYdmLPrVmasVI5NkVTm4aI4BhPvURjHzsLqg3zKu9TqaK22/zs8aSVCT@DIUaBEhRoNWlAGIhAH5aACVIIqUA1qQC149gU "Python 2 – Try It Online")
Function that terminates with `ZeroDivisionError` for no output. This happens when the power-of-10 `c` that we're using as a divisor is a multiple of `2**n`, which causes `c%2**n` to reset to 0. This first happens for `c=10**n`, which is bigger than `2**n` so we're already out of digits.
A probably-cheating version instead terminates with `RuntimeError` for exceeding the maximum recursion depth, though usually we pretend this doesn't exist since it would also trigger for very large inputs that should produce an output.
**36 bytes**
```
f=lambda n,c=1:2**n/c%2or-~f(n,c*10)
```
[Try it online!](https://tio.run/##Rcq7DoIwGIbh/buKfzEcopG/nEkYXR28A8QSmkDbNCXK4q1XNpd3ePLa3c9GixCmfhnW52sgfR577kSa6ut4EsZdvlN8WMpZEt6zWiRxB/JuP0rWKe1pipW2m4@TBCQ/o7SeHpv2apU354z7j9HdaBkFhkCOAiUq1GjQgjMwgwU4BxfgElyBa3ADbiGyHw "Python 2 – Try It Online")
[Answer]
# [Julia 1.0](http://julialang.org/), 32 bytes
```
!x=prod(findmax(digits(2^x).%2))
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/X7HCtqAoP0UjLTMvJTexQiMlMz2zpFjDKK5CU0/VSFPzf0FRZl5JTp6ehoaBlZGBpoKerZ2CniKEo/kfAA "Julia 1.0 – Try It Online")
1-indexed, works for `0`, and returns `0` for no odd digit
[Answer]
# Haskell, 46 bytes
```
(succ<$>).findIndex(odd.ord).reverse.show.(2^)
```
[Try it online!](https://tio.run/##VY69bsMwDIT3ewoOGeyhgun8B2mWZinQTt0LqBYTC7GlQFLS9uld2ejQcjp@4N2x1fEiXTcMtr/6kOiok1ZPrQ74C15sTP/Aq/7@EKDX1tEjGQ/K00miINo8u5ThqGi3o7cUrDvTw4Eyn@6sSxJ0k2hGN9dZJ5EU9fpKRWz9Z9an4Pupgaq8FfHWNPvZoVQn63K4ka/CG6N8MKUKcpcQRY1OVdTvZTb8/jDKKX0YKjBqzLHAEiusscEWnCGDa/AcvAAvwSvwGrwBb1FX@AE)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~8~~ 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
oRÅΔÉ
```
0-indexed. Outputs `-1` if there are no odd digits. Also works for \$n=0\$.
[Try it online](https://tio.run/##yy9OTMpM/f8/P@hw67kphzv//ze0BAA) or [verify the first 26 test cases](https://tio.run/##yy9OTMpM/W9kemySn72SwqO2SQpK9n7/84MOt56bcrjzf63OfwA).
**Original 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) approach:**
```
oSÉRƶ0Kß
```
1-indexed. Outputs an empty string if there are no odd digits. Also works for \$n=0\$.
[Try it online](https://tio.run/##yy9OTMpM/f8/P/hwZ9CxbQbeh@f//29oCQA) or [verify the first 26 test cases](https://tio.run/##yy9OTMpM/W9kemySn72SwqO2SQpK9n7/84MPdwYd22bgfXj@f53/AA).
**Explanation:**
```
o         # Push 2 to the power of the (implicit) input-integer
 R        # Reverse it
  ÅΔ      # Find the first 0-based index that's truthy for, or -1 if none are:
    É     #  Is the digit odd?
          # (after which the result is output implicitly)
```
```
o         # Push 2 to the power of the (implicit) input-integer
 S        # Convert it to a list of digits
  É       # Check for each digit whether it's odd (1 if odd; 0 if even)
   R      # Reverse this list
    ƶ     # Multiply each value by its 1-based index
     0K   # Remove all 0s
       ß  # Pop and keep the minimum, or an empty string if the list was empty
          # (which is output implicitly as result)
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `gA`, ~~7~~ 5 bytes
```
Ef∷ṘT
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJnQSIsIiIsIkVm4oi34bmYVCIsIiIsIjFcbjJcbjNcbjRcbjVcbjZcbjdcbjhcbjlcbjEwXG4xMVxuMTJcbjEzXG4xNFxuMTVcbjE2XG4xN1xuMThcbjE5XG4yMCJd)
`-2` thanks to @lyxal!
[Answer]
# [Arturo](https://arturo-lang.io), 40 bytes
```
$=>[index reverse map digits^2&=>[&%2]1]
```
[Try it!](http://arturo-lang.io/playground?LnPBpN)
0-indexed; no result returns `null`.
```
$=>[            ; a function where input is assigned to &
    ^2&         ; two raised to the input power
    digits      ; get its digits as a list
    map         ; map over the digits...
    =>[&%2]     ; ...modulo two
    reverse     ; reverse
    index ... 1 ; get the index of the leftmost 1
]               ; end function
```
[Answer]
# [Python 2](https://docs.python.org/2/), 53 bytes
```
lambda n:`[int(c)%2for c in`2**n`[::-1]]`.find('1')/3
```
An unnamed function that accepts a non-negative integer, \$n\$, and returns the 0-indexed position of the last odd digit of \$2^n\$, or \$-1\$ if all the digits are even.
**[Try it online!](https://tio.run/##FczNCoQgGEbhfVfxbUKNfsiJFkLdSAVajZNQbyFtunrHzvrhXM@9nZDBdmPYzTGvhqD04HDzRaTSnp4WctAyy6AHpYp6mnRpHVbOaiaqT3gJIiFv8PvythEqodjl44SQE@t6lpPlEOEP "Python 2 – Try It Online")**
Note: this actually gets scuppered at \$n=63\$ when long ints come into play and the representation of `2**n` acquires a trailing `L`. However, this is about where floating point errors would creep in with division-based methods anyway (this errors while they may start giving incorrect results). This can be dealt with by inserting `if'L'>c` between the `]]` for \$60\$.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~46~~ ~~45~~ 53 bytes
*-1 byte thanks to @The Thonnu*  
*+8 bytes so it always terminates (added `%(i-2*x)`)*
```
i=2**input()
x=0
while~i/10**x%2%(i-2*x):x+=1
print x
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P9PWSEsrM6@gtERDk6vC1oCrPCMzJ7UuU9/QQEurQtVIVSNT10irQtOqQtvWkKugKDOvRKHi/39DAwA "Python 2 – Try It Online")
Zero indexed, gives a `ZeroDivisionError` for \$n=1,2,3,6,11\$.
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 36 bytes
```
n->valuation(x*Pol(digits(2^n)%2),x)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMHiNAXbpaUlaboWN1XydO3KEnNKE0sy8_M0KrQC8nM0UjLTM0uKNYzi8jRVjTR1KjRhatPyizTyFGwVDHQUjIC4oCgzrwQooKSgawck0jTyNDWhahcsgNAA)
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `M`, 5 [bytes](Https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
OdɗrV
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faGm0kq9S7IKlpSVpuhbL_FNOTi8KW1KclFwMFVqwyNAAwgIA) or [verify the first 20 test cases](https://ato.pxeger.com/run?1=m728JKM0Ly_faMEqI4MjG13UObUPLVpaWpKma7HMP-Xk9KKwJcVJycWLfQ8thoguWAChAQ)
0-indexed. Outputs `[]` if there is no odd digit. Works for \$n=0\$.
#### Explanation
```
OdɗrV  # Implicit input
O      # Push 2 ** input
 d     # Convert to digits
  ɗ    # Each mod 2
   r   # Reverse the list
    V  # Truthy indices
       # Take the minimum
       # Implicit output
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~49~~ 47 bytes
```
#&@@Reverse@IntegerDigits[2^#]~Position~_?OddQ&
```
[Try it online!](https://tio.run/##FcixCsIwEADQ3a8oBDIplI6FagYRnFrbMUQJ6SU9sBdITsf8esQ3vt3yBrtldLb6ZmiqkErN8IWUQd2JIUC6YkDOunsKU6aYkTFSeV3GdX3IOnqvbx9y/@z7/I5M5jAlJNbidPZKGFkWZ6nMlgLo9ti1pv4A "Wolfram Language (Mathematica) – Try It Online")  
`-2` thanks to @att
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 42 bytes
```
i=$[2**n] i=${i#${i%[13579]*}}; echo ${#i}
```
[Try it online!](https://tio.run/##S0oszvifll@kkKeQmadQbainZ2RQa62Qks@loFBQlJlXkqagrmqUElOirqCS9z/TViXaSEsrL1YByKrOVAZi1WhDY1Nzy1itWqC21OSMfAWVauXM2v8p@Xmp/wE "Bash – Try It Online")
[Answer]
# [R](https://www.r-project.org), 30 bytes
```
\(n)match(1,2^n%/%10^(0:n)%%2)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMHynPyU_AIj26WlJWm6FvtiNPI0cxNLkjM0DHWM4vJU9VUNDeI0DKzyNFVVjTQhijYXJxYU5FRqGFoZGehAtENlFiyA0AA)
[Answer]
# [MATL](https://github.com/lmendo/MATL), 8 bytes
```
WVooPfX<
```
Output is empty if no solution.
[Try it online!](https://tio.run/##y00syfn/PzwsPz8gLcLm/38jAwA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmv5PA/PCw/PyAtwua/uq6ueoTLf0MrIwMA).
### How it works
```
W    % Implicit input. 2 raised to that
V    % Convert to char vector
o    % Convert each char to code point
o    % Modulo 2
P    % Reverse
f    % Find: gives 1-based indices of non-zeros
X<   % Minimum. Implicit display
```
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 7 bytes (14 nibbles)
```
/`?\`@~^2$%$~
```
Returns `0` if there are no odd digits.
```
/`?\`@~^2$%$~   # full program
             $  # with implicit arg added;
 `?             # find the indices of elements that are truthy by
          %$~   # modulo 2 (default)
                # of
   \            # reverse of
    `@~         # digits in base 10 (default) of
       ^2$      # 2^input
/               # finally fold over this list from right, returning
                # left element each time 
                # (so returns first element)
```
[![enter image description here](https://i.stack.imgur.com/dNlH9.png)](https://i.stack.imgur.com/dNlH9.png)
[Answer]
# [Python 2](https://docs.python.org/2/), 58 bytes
```
lambda n:"".join(`int(i)%2`for i in`2**n`[::-1]).find("1")
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728oLIkIz_PaMHiNNuYpaUlaboWN61yEnOTUhIV8qyUlPSy8jPzNBIy80o0MjVVjRLS8osUMhUy8xKMtLTyEqKtrHQNYzX10jLzUjSUDJU0oSaogZRVAJUpFCXmpadqGOooGBlqWnEpKBQUAY1SqNBRSNOogKpesABCAwA)
# [Python 3](https://www.python.org), 65 bytes
```
lambda n:"".join(str(int(i)%2)for i in str(2**n)[::-1]).find("1")
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3HXMSc5NSEhXyrJSU9LLyM_M0ikuKNDLzSjQyNVWNNNPyixQyFTLzFECiRlpaeZrRVla6hrGaemmZeSkaSoZKmlCD1EFKK0BKixLz0lM1DHUUjAw1rbgUFAqKQMZV6CikaVRoQpUvWAChAQ)
[Answer]
# [Scala](http://www.scala-lang.org/), 53 bytes
Thanks for the comment to save so many bytes.
[Try it online!](https://tio.run/##LY1BS8NAEIXv@ysepcIu1iXmGGyh3jx4EvEgUsZ0E1fS2TA7VKXkt8dt9TDDvHkf7@WWBprjYUyiyGfhiTkpaUzsleIgoTUmvX@GVvFIkXEywD50OBRhSfrcYCtCP69PKpH7N9fgmaNifSGBLoll3N2ggibUlfv/A2PhdWCbF0teYXnqLLtp4S7uZM5jjjSgax5Y15uySuZ8H/ty2dr5MX3ZnfOa/oq9hGOQHHzkffh@@QgS7O6q3lTu@naezPwL)
1-indexed. "return 0" means missing odd numbers.
```
BigInt(2).pow(_).toString.reverse.indexWhere(_%2>0)+1
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 13 bytes
```
;2^₍↔i%₂ʰℕ₁ʰt
```
[Try it online!](https://tio.run/##ASsA1P9icmFjaHlsb2cy//87Ml7igo3ihpRpJeKCgsqw4oSV4oKByrB0//8xMP9a "Brachylog – Try It Online")
### Explanation
```
;2^₍             2^Input
    ↔            Reverse the number
     i           Take a [Digit, Index] of that number
      %₂ʰ        [Digit mod 2, Index]
         ℕ₁ʰ     Digit mod 2 must be in [1,+inf)
            t    Output = Index
```
`↔` would mess up indexing in case we reverse a number that ends with 0, but powers of 2 cannot have trailing 0.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 46 (40) bytes
40 bytes if input is allowed to be \$n = 2^t\$ instead of \$t\$ (switched notation). After solving, I saw xnors answer which I think is similar but deals with the power of 2.
```
f=lambda n,j=1:j if n%2else f(n//10,j+1)
```
[Try it online!](https://tio.run/##DcTRCsIgFADQZ/2K@xLqEpYbgxD8GGtayroTvQ@N6Nut83DKQc8d52upvUe3@ddt9YA6O2MzpAh4msLWAkSJ42guOp@N6nGvQJAQqsdHkEbDvCjLGdXjPys1IckoPlFOw0Dqq4WGgCs4IRRn4X0PhWzxrfH@Aw "Python 3.8 (pre-release) – Try It Online")
**26** from xnor by accumulating using 1+f instead of j.
```
f=lambda n:n%2or-~f(n//10)
```
Using this in a \$2^\cdot\$ wrapper gives:
**43** 58:
```
lambda t:f(2**t)
f=lambda n:n%2or-~f(n//10)
```
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 46 bytes
```
f=lambda n,j=0:j if 2**n//10**j%2else f(n,j+1)
```
[Try it online!](https://tio.run/##XcpBDoMgEEDRNZ5iNo1ATRSJSUPiYWiFFmJHQmdRYzw7Zd3N37yfdnptqG8pl@Ln1b7viwXs4jyYCMHDKCX2vRqkjJfRrR8Hnle@KlH8loEgIGSLT8dVB3oSpmGU91qWckDivj3I6OU0cHhO4mxFw9z34RKZ/wFtxfID "Python 3.8 (pre-release) – Try It Online")
37 from xnor by accumulating using 1+f instead of j. (Identical except for `n//j` since python 3)
```
f=lambda n,j=1:2**n//j%2or-~f(n,j*10)
```
[Answer]
# [Piet](https://www.dangermouse.net/esoteric/piet.html) + [ascii-piet](https://github.com/dloscutoff/ascii-piet), 154 bytes (11×14=154 codels)
```
tldfm?liafqaqQ      ?   i  I rrrjje   e  A ?        e  R biqaasccmu  _             Saeeumcccccc?sVi    qq      Vt    qq sss  Nd    qq  a   Clliqqqq??qfaks
```
Infinite loop for `n = 0, 1, 2, 3, 6, 11, ...` (No odd digits in `n^2`). Outputs correctly for anything with an odd digit. If you want to see how it works, make sure to add input `n` before executing.
[Try Piet online!](https://piet.bubbler.one/#eJx1kcEOgjAQRP9lz3PotqVUfoV4MFgTElQS9GT8d7ttQ6pgdpIuy2N2gBcN93Ogru8VHFiDDZjBXq4U2MnAymlhj-j5gF_5qldrk1mdysfitsLW3hVLv3HdsLqgVrakRFExbJPEaNY8-zH3ZAR1aUeL5FLsannZIqD6etZKiK1pBHc5kyqPWnHT_9xcdaOJpMu_wpaSb-XlNILKOxxBS5ipIwJN4zU3YRmou5ymJYDG2_x8yPj9AYFFaAM)
![](https://piet.bubbler.one/api.svg?11,14,0,6,12,13,11,18,6,10,16,13,4,16,4,4,19,19,19,19,19,19,18,19,19,19,10,19,19,10,19,2,2,2,8,8,17,19,19,19,17,19,19,16,19,18,19,19,19,19,19,19,19,19,17,19,19,2,19,14,10,4,16,16,3,15,15,11,5,19,19,18,19,19,19,19,19,19,19,19,19,19,19,19,19,3,16,17,17,5,11,15,15,15,15,15,15,18,3,1,10,19,19,19,19,4,4,19,19,19,19,19,19,1,0,19,19,19,19,4,4,19,3,3,3,19,19,7,12,19,19,19,19,4,4,19,19,16,19,19,19,15,6,6,10,4,4,4,4,18,18,4,13,16,9,3)
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
V%2↔d`^2
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8eGOxUYG/8NUjR61TUlJiDP6/x8A "Husk – Try It Online")
```
V           # Index of first element that is truthy when  
 %2         # modulo 2
   ↔        # of the reverse of
    d       # the decimal digits of
     `^2    # 2^input
```
[Answer]
# [C++ (gcc)](https://gcc.gnu.org/), 56 bytes
```
[](int&n){int p=1;for(n=1<<n;n%2-!!n;n/=10)++p;n=n?p:0;}
```
[Try it online!](https://tio.run/##VVBhT4MwEP3Or7hhNCAjAlMTaYsfjL9i4wMpZRK3QmgxRMJfF48yMtaU9t1794678rr2j5yPWasrKNi4T51S6gfp9nhBzUJSVI0jWUipJPI@8jcbvJ9YGLieVxPJ5HsdB2QYiXVXSn5qcwG0rJRuRHZOVtyP4LpqEmsqe85K6bi9BbiUzuN4FilqCYiuxkjkwKAPtxAsOzIbwW7Bzyt@t@IRvCIYiPkBr6TSwL@y5hFPwb9Fs0@n4vah@4wO3dsHfi/2Ftbxzr64cXqYXgRKmYsObQG5QDq3rspf4Sw9uwQ8z8guzONNa7JrtBqB3NAC6cW8N3p6TSgc7d6mK0zXV8o0wKtWA6VLVxRs8BM8EKk5NHgZXTCmUsMfpD2XGqxh/OPFKTuq0fexKDvK1vOi7B8 "C++ (gcc) – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 39 bytes
```
~`.+
.+¶$$.($&*$(2$*)_
-1L$`[13579]
$.'
```
[Try it online!](https://tio.run/##BcGxDcIwFEXR/s7xAZMoVp4dx/EENGyAEKagoKGIqBkrA2Qxc876@r4/T7WDu9T2q77H9/tm5p0dO3PBuvODQVerN8WUyx3zp9ZEIDKRmMksFDQioYAimlBCM8poQYUw/gE "Retina – Try It Online") Link includes test cases. 0-indexed. Outputs nothing if no odd digit exists. Explanation:
```
.+
.+¶$$.($&*$(2$*)_
```
Replace the input with code to calculate that power of `2`. (I could save two bytes by removing the `)_` at the end but this actually prevents a crash in Retina which I feel is not an ideal way to handle zero input.)
```
~`
```
Execute the code to generate the power of `2`.
```
-1L$`[13579]
```
Match the last odd digit.
```
$.'
```
Output the number of digits after it.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-g`](https://codegolf.meta.stackexchange.com/a/14339/), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
0-indexed, returns `undefined` if there's no odd digits
```
õ!²Ìì Ôðu
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWc&code=9SGyzOwg1PB1&input=MTc)
```
õ!²Ìì Ôðu     :Implicit input of integer U
õ             :Range [1,U]
 !²           :Raise 2 to the power of each
   Ì          :Last element
    ì         :Digit array
      Ô       :Reverse
       ð      :0-based indices of elements that truthy (1)
        u     :  Mod 2
              :Implicit output of first element
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes
```
Ｉ⌕⮌﹪↨Ｘ²Ｎχ²¦¹
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwy0zL0UjKLUstag4VcM3P6U0J1/DKRHIDsgvTy3SMNJR8MwrKC3xK81NAnI1NXUUDA2AhBGYpampaf3/v6Hhf92yHAA "Charcoal – Try It Online") Link is to verbose version of code. 0-indexed. Outputs `-1` if no odd digit exists. Explanation:
```
      ²         Literal integer `2`
     Ｘ          Raised to power
       Ｎ        Input integer
    ↨           Converted to base
        χ       Predefined variable `10`
   ﹪            Vectorised modulo
         ²      Literal integer `2`
  ⮌             Reversed
 ⌕              Find index of
           ¹    Literal integer `1`
                Implicitly print
```
Actually outputting the last odd digit also takes 12 bytes:
```
ＦＩＸ²Ｎ¿﹪Ｉι²Ｐι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBwzmxuEQjIL88tUjDSEfBM6@gtMSvNDcptUhTU1MhM01Bwzc/pTQnH6IuU1NHwQgo7luaU5JZUJSZBxKy/v/f4L9uWQ4A "Charcoal – Try It Online") Link is to verbose version of code. Outputs nothing if no odd digit exists. Explanation:
```
ＦＩＸ²Ｎ
```
Loop over the digits.
```
¿﹪Ｉι²
```
If the digit is odd, then...
```
Ｐι
```
... overprint any previous result.
[Answer]
# [Desmos](https://desmos.com/calculator), 50 bytes
```
I=[0...nlog2]
f(n)=I[mod(floor(2^n/10^I),2)=1].min
```
Counting starts from 0 instead of 1, which is allowed as per the OP. Outputs `undefined` for all-even digits.
[Try It On Desmos!](https://www.desmos.com/calculator/u01kewkyao)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/a8tqzjvnbs)
[Answer]
# JavaScript, 61 bytes
Nearly double the length of the [other JS answer](https://codegolf.stackexchange.com/a/261910/108556) (and a slightly more naive implementation), but spent a bit of time on it, so might as well post it.
Returns `-0` when there is no odd digit.
```
n=>-(~(l=(z=[...2**n+'']).findLastIndex(i=>i%2))&&l-z.length)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LcxNCsIwEEDhvacYCraTxgbNyr_pXvAG4kJsWgNhBmwE6cKLuCmih_I2Fuzqe6v3fLNUrn8JfW6xLpZfYioLfGAg7OhgjLF5zjrLjsrUnqv9qY07rtwdPZV-apVK01B0Jjhu4kWNk1UtVwwuggeCxWZgS2DnQ2itJgBn4VaCM0Ea9KAhWSczEPRqHPT93x8)
]