[Question]
  [
## The Sequence
Everyone knows the only even prime number is `2`. Ho-hum. But, there are certain even numbers `n` where, when concatenated with `n-1`, they *become* a prime number.
For starters, `1` isn't in the list, because `10` isn't prime. Similarly with `2` (`21`), and `3` (`32`). However, `4` works because `43` is prime, so it's the first number in the sequence `a(1) = 4`. The next number that works (neither `6` (`65`) nor `8` (`87`) work) is `10`, because `109` is prime, so `a(2) = 10`. Then we skip a bunch more until `22`, because `2221` is prime, so `a(3) = 22`. And so on.
Obviously all terms in this sequence are even, because any odd number `n` when concatenated with `n-1` becomes even (like `3` turns into `32`), which will never be prime.
This is sequence [A054211](http://oeis.org/A054211) on OEIS.
## The Challenge
Given an input number `n` that fits somewhere into this sequence (i.e., `n` concatenated with `n-1` is prime), output its position in this sequence. You can choose either 0- or 1-indexed, but please state which in your submission.
## Rules
* The input and output can be assumed to fit in your language's native integer type.
* The input and output can be given [in any convenient format](http://meta.codegolf.stackexchange.com/q/2447/42963).
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* If possible, please include a link to an online testing environment so other people can try out your code!
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.
## Examples
The below examples are 1-indexed.
```
n = 4
1
n = 100
11
n = 420
51
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~8~~ 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
·∏ä≈º·πñV√ÜPS
```
A monadic link taking a sequence member and returning its index in the sequence.
**[Try it online!](https://tio.run/##y0rNyan8///hjq6jex7unBZ2uC0g@P///4YGBgA "Jelly ‚Äì Try It Online")**
### How?
```
·∏ä≈º·πñV√ÜPS - Link: number, n
·∏ä       - dequeue (implicit range) = [ 2   , 3   , 4   ,... ,              n         ]
  ·πñ     - pop (implicit range)     = [   1 ,   2 ,   3 ,... ,                  n-1   ]
 ≈º      - zip                      = [[2,1],[3,2],[4,3],... ,             [n , n-1]  ]
   V    - evaluate as Jelly code   = [ 21  , 32  , 43  ,... ,         int("n"+"n-1") ]
    √ÜP  - is prime? (vectorises)   = [  0  ,  0  ,  1  ,... , isPrime(int("n"+"n-1"))]
      S - sum
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~80~~ ~~75~~ 70 bytes
*5 bytes save thanks to Laikoni*
```
p x=all((>0).mod x)[2..x-1]
g n=sum[1|x<-[4..n],p$read$show=<<[x,x-1]]
```
[Try it online!](https://tio.run/##FcqxCsMgFEDRvV/xBocEzCNaCx00PyIOQkISqkZiS97Qf7d2uHCGu/nyWkKoNQMZH0LXTWOP8ZiBeisRaRDutkIy5ROt@JIerEJMjmd2Ln5mZTsuo7Ul/j9djX5PJp97erPoM6xWcRAjBylbzfeWan48Xf0B "Haskell ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~12, 10~~, 8 bytes
```
;‚ÄôV√ÜP¬µ‚Ç¨S
```
[Try it online!](https://tio.run/##y0rNyan8/9/6UcPMsMNtAYe2PmpaE/z//39DAwMA "Jelly ‚Äì Try It Online")
1-2 bytes saved thanks to @nmjmcman101, and 2 bytes saved thanks to @Dennis! 
Explanation:
```
     ¬µ‚Ç¨   # For N in range(input()):
;         #   Concatenate N with...
 ‚Äô        #   N-1
  V       #   And convert that back into an integer
   √ÜP     #   Is this number prime?
       S  # Sum that list 
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ ~~8~~ 7 bytes
### Code
```
∆íNN<¬´pO
```
Uses the **05AB1E** encoding. [Try it online!](https://tio.run/##MzBNTDJM/f//2CQ/P5tDqwv8//83NDAAAA "05AB1E ‚Äì Try It Online")
### Explanation
```
∆í          # For N in [0 .. input]..
 NN<¬´      #   Push n and n-1 concatenated
     p     #   Check for primality
      O    #   Sum the entire stack (which is the number of successes)
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~13~~ ~~11~~ 10 bytes
`1`-indexed solution:
```
#»Ø·πódS¬§+d‚Üê·∏£
```
[Try it online!](https://tio.run/##AR4A4f9odXNr//8jyK/huZdkU8KkK2TihpDhuKP///80MjA "Husk ‚Äì Try It Online")
### Ungolfed/Explanation
```
         ·∏£ -- in the range [1..N]
#          -- count the number where the following predicate is true
        ‚Üê  --   decrement number,
    S  d   --   create lists of digits of number and decremented 
     ¬§+    --   concatenate,
   d       --   interpret it as number and
 »Ø·πó        --   check if it's a prime number
```
Thanks @Zgarb for `-3` bytes!
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), ~~15~~ ~~14~~ ~~12~~ ~~11~~ ~~9~~ 8 bytes
1-indexed.
```
√ásiZ√Ñ√É√®j
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=x3NpWsTD6Go=&input=NDIw)
```
√á            :Map each Z in the range [0,input)
 s           :  Convert to string
  i          :    Prepend
   Z√Ñ        :    Z+1
     √É       :End map
      √®      :Count
       j     :  Primes
```
[Answer]
# [Python 2](https://docs.python.org/2/), 87 bytes
*-2 bytes thanks to [@officialaimm](https://codegolf.stackexchange.com/users/59523/officialaimm)*. 1-indexed.
```
lambda n:sum(all(z%v for v in range(2,z))for i in range(4,n+1)for z in[int(`i`+`i-1`)])
```
**[Test Suite.](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPqrg0VyMxJ0ejSrVMIS2/SKFMITNPoSgxLz1Vw0inSlMTJJaJEDPRydM2BAtWAQWjM/NKNBIyE7QTMnUNEzRjNf8XFIGE0jRMNDW5YGxDAwMknokRkPcfAA "Python 2 ‚Äì Try It Online")**
[Answer]
# [Pyth](http://pyth.readthedocs.io), 12 bytes
```
smP_s+`d`tdS
```
**[Try it online!](https://pyth.herokuapp.com/?code=smP_s%2B%60d%60tdS&input=420&debug=0) or [Verify all Test Cases.](http://pyth.herokuapp.com/?code=smP_s%2B%60d%60tdS&input=4&test_suite=1&test_suite_input=420%0A100%0A4&debug=0)**
---
# How?
```
smP_s+`d`tdSQ  -> Full Program. Takes input from Standard Input. Q means evaluated input
                  and is implicit at the end.
 m         SQ  -> Map over the Inclusive Range: [1...Q], with the current value d.
    s+`d`td    -> Concatenate: d, the current item and: td, the current item decremented. 
                  Convert to int.
  P_           -> Prime?
s              -> Sum, counts the occurrences of True.
```
[Answer]
# [R√∂da](https://github.com/fergusq/roda), 73 bytes
```
{seq 3,_|slide 2|parseInteger`$_2$_1`|{|i|[1]if seq 2,i-1|[i%_!=0]}_|sum}
```
[Try it online!](https://tio.run/##TYxBCsIwEEXX5hQjVFCo0ERXQg/gGWKYFprogK01aVeZnD2mOxf/8Rf/P/8Z@hzFzsGthUeOwX7hUiOHNw0WFM@9D/Y@LfZpfVehqlB2HJlYS0MOtrmq6SxZ0wH3bWNS@a5jykmIsacJivvfAQgMel7D64inUp0pmD1NC6BI@SpkI9TGpkT9AA "R√∂da ‚Äì Try It Online")
1-indexed. It uses the stream to do input and output.
Explanation:
```
{
seq 3,_| /* Create a stream of numbers from 3 to input */
slide 2| /* Duplicate every number except the first and the last
            to create (n-1,n) pairs */
parseInteger`$_2$_1`| /* Concatenate n and n-1 and convert to integer */
{|i| /* For every i in the stream: */
    [1]if seq 2,i-1|[i%_!=0] /* Push 1 if i is a prime
                                (not divisible by smaller numbers) */
}_|
sum /* Return the sum of numbers in the stream */
}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 14 bytes
```
lfP_Tms+`d`tdS
```
[Try it online!](https://pyth.herokuapp.com/?code=lfP_Tms%2B%60d%60tdS&input=420&debug=0)
**Explanation**
```
              Q    # Implicit input
             S     # 1-indexed range
     m             # For d in range [1, Q]...
      s+`d`td      # Concatenate d and d - 1
 fP_T              # Filter on primes
l                  # Return the length of the list
```
[Answer]
# [Perl 6](http://perl6.org/), 45 bytes
```
{first :k,$_,grep {is-prime $_~.pred},1..‚àû}
```
[Try it online!](https://tio.run/##DcpLDsIgFAXQrdw0pCMkFNES@9kKMREM0abk4aQhOHYVLs6NYMfnREfPc102tB5TzT5QeuHy4MzyO7mIHNIhUlgcmH2LSO5WeCfE7/MtdUC6bmiYxTQj@32UBn4ljBqdhFJQGkcNrXAy6CV6A2N2kvNQ/w "Perl 6 ‚Äì Try It Online")
The `grep` produces the sequence of qualifying numbers, then we look for the key (`:k`) (ie, the index) of the `first` number in the list that equals the input parameter `$_`.
[Answer]
# C, ~~99~~ 94 bytes
1 indexed. It pains me to write primality tests that are so computationally wasteful, but bytes are bytes after all.
If we allow some really brittle stuff, compiling on my machine without optimizations with GCC 7.1.1 the following 94 bytes works (thanks [@Conor O'Brien](https://codegolf.stackexchange.com/users/31957/conor-obrien))
```
i,c,m,k;f(n){c=i=1;for(;++i<n;c+=m==k){for(k=m=1;m*=10,m<i;);for(m=i*m+i-1;++k<m&&m%k;);}n=c;}
```
otherwise these much more robust 99 bytes does the job
```
i,c,m,k;f(n){c=i=1;for(;++i<n;c+=m==k){for(k=m=1;m*=10,m<i;);for(m=i*m+i-1;++k<m&&m%k;);}return c;}
```
---
Full program, a bit more readable:
```
i,c,m,k;
f(n){
    c=i=1;
    for(;++i<n;c+=m==k){
        for(k=m=1;m*=10,m<i;);
        for(m=i*m+i-1;++k<m&&m%k;);
    }
    return c;
}
int main(int argc, char *argv[])
{
    printf("%d\n", f(atoi(argv[1])));
    return 0;
}
```
[Answer]
## JavaScript (ES6), ~~¬†49 48¬†~~ 47 bytes
1-indexed. Limited by the call stack size of your engine.
```
f=n=>n&&f(n-2)+(p=n=>n%--x?p(n):x<2)(x=n+[--n])
```
[Try it online!](https://tio.run/##HY7LDoIwEEX3fMVshJlACVYMRC2u/ArCokHqI2RKwBj@vg4uTu4jd3Hf9muXfn5NH8X@PoTgDJuG49ghK00pTv@8U2q9Tsh0Wi@acDWctkpxR@Hclhnsiwy0FsQfhFL8sc6gkr4SrettU3RR7vx8s/0TGUwTAfSeFz8O@egfmFhMIAUWEgIDW5AXRBGFHw "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Tidy](https://github.com/ConorOBrien-Foxx/Tidy), 33 bytes
```
index({n:prime(n.n-1|int)}from N)
```
[Try it online!](https://tio.run/##DcpBCsIwEAXQvaf4dDUDSUmlq4AewTuUNIEBM5YwoKX27NG3fibr3gvirYuu@UOHxq1JzaSj@ukranyW9qp4cLf0f0g0O0whOMzXwJe6bHRAEfFuYvmppA4DvL9jcCikzDgdLHH/AQ "Tidy ‚Äì Try It Online")
## Explanation
The basic idea is to create a sequence of the valid numbers then return a curried index function.
```
index({n:prime(n.n-1|int)}from N)
      {n:                }from       select all numbers `n` from...
                               N     the set of natural numbers, such that:
               n.n-1                     `n` concatenated with `n-1`
                    |int                 ...converted to an integer
         prime(         )                ...is prime
index(                          )    function that returns index of input in that sequence
```
[Answer]
# Mathematica, 77 bytes
```
Position[Select[Range@#,PrimeQ@FromDigits[Join@@IntegerDigits/@{#,#-1}]&],#]&
```
[Answer]
# [Vyxal 3](https://github.com/Vyxal/Vyxal/tree/version-3) `L`, 6 bytes
```
Œ©v&‚Äú‚åä·πÑ
```
[Try it Online!](https://vyxal.github.io/latest.html#WyJMIiwiIiwizql2JuKAnOKMiuG5hCIsIiIsIjQyMCIsIjMuNC4xIl0=)
1-indexed
```
Œ©v&‚Äú‚åä·πÑ¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äè‚Äã‚Å¢‚Å†‚Å°‚Äå¬≠
Œ©       # ‚Äé‚Å°filter from the range [0... input]
 v&‚Äú‚åä   # ‚Äé‚Å¢concatenate n+1 and convert to integer
     ·πÑ  # ‚Äé‚Å£prime?
# ‚Äé‚Å§L flag gets the length of the top of the stack
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal/tree/version-2), 6 bytes
```
'‚ÄπJ√¶;L
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2&c=1#WyIiLCIiLCIn4oC5SsOmO0wiLCIiLCI0MjAiXQ==)
```
     L # Number of values
'   ;  # Between (implicit) 1 and n
 ‚ÄπJ    # Where n ++ (n-1)
   √¶   # Is prime
```
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 25 bytes
```
[:|p=p-¬µa*z^_l!a$|+a-1}?p
```
## Explanation
```
[:|     FOR a = 1 to <n>
p=p-    Decrement p (the counter) by
¬µ       -1 if the following is prime, or 0 if not
        For the concatenating, we multiply 'a' by 10^LENGTH(a), then add a-1$‚îòp
        Example 8, len(8) = 1, 8*10^1 = 80, add 8-1=7, isPrime(87) = 0
a*z^_l!a$|+a-1
}       Close the FOR loop - this also terminates the prime-test
?p      Print p, the 0-based index in the sequence.
```
This uses some pretty involved math-thing with a cast-to-string slapped on for good measure. Making a version hat does solely string-based concatenation is one byte longer:
```
[:|A=!a$+!a-1$‚îòp=p-¬µ!A!}?p
```
[Answer]
# [PHP](https://php.net/), 203 bytes
```
<?php $n=($a=$argv[1]).($a-1);$p=[2];$r=0;for($b=2;$b<=$n;$b++){$x=0;if(!in_array($b,$p)){foreach($p as $v)if(!($x=$b%$v))break;if($x)$p[]=$b;}}for($b=1;$b<=$a;$b++)if(in_array($b.($b-1),$p))$r++;die $r;
```
[Try it online!](https://tio.run/##TY7BCoMwEETP5issTCEhbTG9xtAPESmJaJWChhTEUvz2dI0Uelp2Znbf@N7HWN587xlGw2ENbHjMlarFhbazEprBm@pa0wym0KybAoczVw1XGow0pBQflmHZ3Gzo@GEY7zYE@6bcCV5sbkZnrW16Dp/bV45ZkJbCnA7hjqQIR5En/dh0LCkBX9Vkk7iy9cdWO9vu7MT8Q1JvR70TmV4gSKlZ2/RTjqBjjKoovg "PHP ‚Äì Try It Online")
Uses a 1-based index for output. TIO link has the readable version of the code.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 42+9 = 51 bytes
Uses the `-rprime -n` flags. 1-indexed.
Works by counting all numbers equal to or below the input that fulfill the condition (or more technically, all numbers that fulfill the `n-1` condition). Since the input is guaranteed to be in the sequence, there's no risk of error from a random input like `7` that doesn't "become prime".
```
p (?3..$_).count{|i|eval(i.next+i).prime?}
```
[Try it online!](https://tio.run/##KypNqvz/v0BBw95YT08lXlMvOb80r6S6JrMmtSwxRyNTLy@1okQ7U1OvoCgzN9W@9v9/EyODf/kFJZn5ecX/dYvAwv918wA "Ruby ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 62 bytes
```
->g{(1..g).count{|r|(2...x=eval([r,r-1]*'')).none?{|w|x%w<1}}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y69WsNQTy9dUy85vzSvpLqmqEbDSE9Pr8I2tSwxRyO6SKdI1zBWS11dU1MvLz8v1b66prymQrXcxrC2tvZ/gUJatImRQex/AA "Ruby ‚Äì Try It Online")
1-indexed
[Answer]
## [Python 2](https://docs.python.org/2.7/)**, 85 bytes**
1-indexed
```
lambda n:sum(all(z%v for v in range(2,z))for i in range(3,n)for z in[int(`i+1`+`i`)])
```
[Test](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPqrg0VyMxJ0ejSrVMIS2/SKFMITNPoSgxLz1Vw0inSlMTJJaJEDPWyQMLVQGFojPzSjQSMrUNE7QTMhM0YzX/FxSBhNI0TDQ1uWBsQwMDJJ6JEZD3HwA)
Improvement to Mr. Xcoder's [answer](https://codegolf.stackexchange.com/questions/137387/can-even-numbers-become-prime/137396#137396)
[Answer]
# Java 8, 108 bytes
```
n->{for(long r=0,q=1,z,i;;){for(z=new Long(q+""+~-q++),i=2;i<z;z=z%i++<1?0:z);if(z>1)r++;if(q==n)return r;}}
```
0-indexed
**Explanation:**
[Try it online.](https://tio.run/##hY/BbsIwEETvfMUKqZItJ1GCONWY/gBw4Vj14BoHGcI6cRyqGrm/nprAtaq0K@3OzOHNSV5lbluNp8N5VI3se9hKg7cZgEGvXS2Vht39BWgsHkGRpANSnqSYNk3vpTcKdoAgYMR8fautI1PaiTLrRJWFzHBOJz0I1F@wSS7p2HzOfvKOMZoZseBmFXgQ4cUwtqreytdAualJWFfUMXY/OyGQOu0Hh@B4jCN/ELTDZ5MIniBXaw5wSS3I3juDx/cPSR8N9t@915fCDr5ok@MbJFgosqRTnT/9qiz/SSwXz0ScxfEX)
```
n->{                             // Method with integer parameter and long return-type
  for(long r=0,                  //  Result-long, starting at 0
      q=1,                       //  Loop integer, starting at 1
      z,i;                       //  Temp integers
      ;){                        //  Loop indefinitely
    for(z=new Long(q+""+~-q++),  //   Set z to `q` concatted with `q-1`
        i=2;i<z;z=z%i++<1?0:z);  //   Determine if `z` is a prime,
      if(z>1)                    //   and if it indeed is:
        r++;                     //    Increase the result-long by 1
      if(q==n)                   //   If `q` is now equal to the input integer
        return r;}}              //    Return the result
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 10 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
1- Indexed
```
√Ñm‚ñ¨√°‚îå‚ïï|¬∞œÜ‚ô¶
```
[Run and debug it](https://staxlang.xyz/#p=8e6d16a0dab87cf8ed04&i=4%0A100%0A420&m=2)
**Explanation**
```
Rxr\{$e|pm|+         #Full program, unpacked, implicit input  (Example (4))
R                    #Create [1 to input] range  (ex [1,2,3,4] )             
 x                   #Copy value from x register (ex (4) )
  r                  #Create [0 to input-1] range (ex [0,1,2,3)
   \                 #Create array pair using the range arrays (ex [[1,0],[2,1],[3,2],[4,3]])
    {    m           #Map block
     $e|p            #To string, eval string (toNum), isPrime (ex [1,0] => "10" => 10 => 0)
          |+         #Sum the array to calculate number of truths (ex [0,0,0,1] => 1)
```
]