[Question]
  [
## Challenge:
Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this until it's less than 3. If it reaches 1, your program should output a truthy value, else, the program should output a falsey value.
## Examples:
All of these should give a truthy value:
```
3
4
6
8
10
11
12
14
16
17
18
20
22
23
24
26
27
29
30
32
34
35
37
38
40
41
42
44
46
47
48
50
```
All of these should give falsey values:
```
5
7
9
13
15
19
21
25
28
31
33
36
39
43
45
49
```
## Rules:
* You can either write a program or function.
* You can assume that the input is bigger than 2.
* [Standard loopholes apply](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default)
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest answer wins!
  
[Answer]
# [Retina](http://github.com/mbuettner/retina), 31 bytes
```
.+
$*
+`1(?!(11+)\1+$)11+
1
^1$
```
Prints `0` (falsy) or `1` (truthy).
[Try it online!](http://retina.tryitonline.net/#code=JShHYAouKwokKgorYDEoPyEoMTErKVwxKyQpMTErCjEKXjEk&input=Mwo0CjUKNgo3CjgKOQoxMAoxMQoxMgoxMwoxNAoxNQoxNgoxNwoxOAoxOQoyMA) (The first line enables a linefeed-separated test suite.)
### Explanation
```
.+
$*
```
Convert input to unary by turning input `N` into `N` copies of `1`.
```
+`1(?!(11+)\1+$)11+
1
```
Repeatedly remove the largest prime less than the input. This is based on [the standard primality test with regex](https://codegolf.stackexchange.com/a/57618/8478).
```
^1$
```
Check whether the result is a single `1`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~9~~ 8 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
’ÆRṪạµ¡Ḃ
```
[Try it online!](http://jelly.tryitonline.net/#code=4oCZw4ZS4bmq4bqhwrXCoeG4gg&input=&args=MTIzNA) or [verify all test cases](http://jelly.tryitonline.net/#code=4oCZw4ZS4bmq4bqhwrXigbjCoeG4ggrDh-KCrOKCrEc&input=&args=W1szLCA0LCA2LCA4LCAxMCwgMTEsIDEyLCAxNCwgMTYsIDE3LCAxOCwgMjAsIDIyLCAyMywgMjQsIDI2LCAyNywgMjksIDMwLCAzMiwgMzQsIDM1LCAzNywgMzgsIDQwLCA0MSwgNDIsIDQ0LCA0NiwgNDcsIDQ4LCA1MF0sIFs1LCA3LCA5LCAxMywgMTUsIDE5LCAyMSwgMjUsIDI4LCAzMSwgMzMsIDM2LCAzOSwgNDMsIDQ1LCA0OV1d).
### How it works
```
’ÆRṪạµ¡Ḃ  Main link. Argument: n
     µ    Combine all atoms to the left into a chain.
’           Decrement; yield n - 1.
 ÆR         Prime range; yield all primes in [2, ..., n -1].
   Ṫ        Tail; yield p, the last prime in the range.
            If the range is empty, this yields p = 0.
    ạ       Compute the absolute difference of p and n.
      ¡   Call the chain to the left n times.
          This suffices since each iteration decreases n, until one of the fixed
          points (1 or 2) is reached.
       Ḃ  Bit; return the parity of the fixed point.
```
[Answer]
# Regex (ECMAScript or better), ~~33~~ 32 bytes
```
^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$
```
Takes its input in unary, as a string of `x` characters whose length represents the number.
[Try it online!](https://tio.run/##TY87b8IwFIX/Co0Q3Js0JqCqA67J1IGFoR37kCy4JLc1jmUbSHn89jQMlTqcb/mOdHS@9EGHtWcX8@B4Q37X2G/66byydBy8UPXcOoCTWkzS7hOgVCIre0LbZiW@z9Jhj1swbYddOjmhiM1r9GwrQBEMrwke7/MHRBlUIY81GwIwypPeGLYEiHfK7o3Bc6WMCM5whHE@RslbAKsqYchWscbF7HLhsNIrYOW0D7S0Eaq34gPxT9B/YRfTcjq/aYy1b47J0h604c3Aa1vRfJBkRm4bD5KfFEnOMuwHkzYRnhzpCIxip@O6Bo94DqOR6y9FuL2YSrePIfq@Iq/XrshnRfEL "JavaScript (SpiderMonkey) – Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##bVJdb9swDHzvr@CMDpGSVHX6ONUItmEDBqzb0D6mGaDYcqJUpj1JbpwW/e0Z5XgfBWLAlkmejroTt@pRXWyLh4OpmtoF2FIsTC3GEv7PtMHYkzmn17qjylnTrqzJIbfKe7hRBuEZhpwPKtDyWJsCKqqwu@AMrkG5tV8sOYSNq3cePnW5boKpaecZwGdjNZQZ6l3/yxKR14UWVE@4/NCWpXa6uNWq0A5WPex1kv3ZOYQl53Lo66dB7jaRnzGfrUiDKr4a1IzzNxm21nJTMi/0r1ZZz5LL8XiccP78GnpkYCycJHgmhvCXgQguiWFFuAfpJ9noHkdxDfLlmHv5oULQDsFlwx@prZrYwHNJbqzq2mqF8JSVxKgl3OUKkaQbbNoAGUS1Q47d7X3QlTDIJQw6e5jYKP9Nd4GO2VsMMBhi6ezEcQQhIQaJQ32xBEvliBK@sSaw5IIugfABMKXKFww0Bk40ynlNAbOLdMmngLOTRWE1rsPm@grmEJHwjpbZkhjzjXKLZTfo6SOcLSW8d07tvSiNtaybjrpRbwpAWbuojY6RYSoBrzOc0TKZkMAbFfINOVQRmxPVMWL95CIN@EciP06M2DnVsKFFXjf77@WtwrWmTukUOY9KS2AVtceCvIt3@8QHk2tybOdM0CxeKpdPWXBtvJ9/5YY8DCVL3vqELOHyJT5ncaoOPxmbZ2Iypy/rusmc31@Nz@kTXz7uzg9xcg7pxVWa/gY "Java (JDK) – Try It Online") - Java  
[Try it online!](https://tio.run/##RU7LasMwEPyVJYhYG9u1bOilsmIH0mtPvTWpSEsMAjVxJRdUhPvr7toN9LDDzuxjpj87ez99fANzEqK9vp8ssEISVfV@97zbjtBdHWdeCVlvJUYwHTGMvTOXAVaHy0qO0Frle2sGnuRJ5r/e/EAnOsvLrMTz57zU/KuCdHxgGuX8y5PjybW2rjC29qU8KkJxlDdfc6PM1GoZU5emGE0HnCchgQC0hAjqBwrmCozMr9dLuCUbBS/lX1Zm5DiOWj8@7bWeXjlv1F3aEPIQ0gYP1YYRzIWbwKZJ5JUQvw "Perl 5 – Try It Online") - Perl  
[Try it online!](https://tio.run/##XVBNa8MwDL33V4hgiNUkbdKra3LZBoWxw7Zb05ksc5qA65jEhUDpb8/kstMOEvp4T0@S69yyL13ngI0gIdpGsAE36rMatTN1o3m83axLpbraeNUMF9cbPVa8QlG9b6c4hZispaI66wCwXls/caVeDq/PSmEKBdJIGixW7TBy1stcMCNbgk/84/Pp8IYCb9C3nJnj5EejLUWYFScpo8pGSODp@k0dKqd5mhUY@Hp2ZvjRPMqilOCC@M1wtT5w9zsiHWkA@fwkVgAPZfuXM7uXjz5FSYIkDfxx8qX2TcfZmJJYuF/XnsdznDKLiHALK/aom24IewmgUwoBIQdmxZ1k7v/@xFEsX5yXcpOU5Pk8JyVWuzUjFwzXM1uWPNvl@S8 "PHP – Try It Online") - PCRE  
[Try it online!](https://tio.run/##dVPbjpswEH3PV0zT1cYOkIWs1AcIG6lSf6DqQ6tsiljHAauJQcYoJNX@@qZjs6E0JZYweC5n5pwxrCy9jLHzRyHZrt5wWLwURaUfFM94M8vL8ml07eIN46UWhXzYiDSTaBIsEXJbqH1qzG0Wy1MFSblaQwxfx58Ph18vj/WP4/H7t/zTISfnn4Qs45mzxJ00jbOkz/PpHW7modPm7kyvc8YuTMs4KZ0g6vUksL7i6f5pJKSGfSokofB7BLjKFbp2XJKSesE69iOoMeZxnmgozMkkZOaj0pswxFghMzSWtY5sPitkpcGSDkMrCCiOYNHFViFhlsMhT98zUAMgBvYU@y6ceAeecb0TkhN7YEK6bR0aXXo1yyRKH/VKdSGIDZixBPsilLogAxfKokJ369kKuSETb0KjDkAG6DUxH@I@pzCUxrgcwAXHxjsQUAix@F8sO7@pKSf5oT2tZOAE6wj2fF9xTSoXJs3ENIaKVOg0Enf5nRQilkbrRSyDCBxH9BmbpdXxymK12ALpK59UPFUsJ6THi96bqp5Yu3YELk6H0gGsC96JAlI3VMjkWaJwOKYgGgxv51TUGhYLEP/HvI5un5i9FOSf29P9M3DPlaI3CA83eNWM2cYhfFGqUONoGIdT2BokC@MaAFM1Mjeyw0NLH29s3u/dDv/XxGLcIN5@tbviulYS8DK8nn1v7vtvbLtLs@rs7WyBxE70Dw "C++ (gcc) – Try It Online") - Boost  
[Try it online!](https://tio.run/##NY3NisMwDITveQpherDyY5zuLcHkQbpdKG261eLKQfay6dNn7ZYeNAjNN6PlkW6BPza6L0ESxEdsZW5/YuARxIlSavvSenKmmbLqdW0m/NzXuyxlsF53W4YO/dD1xxHI2eoaBDwQlzIT04V4qMA7b@LiKWnVKaygQFwgOfH3rImT9gd7xPa15TJsesxBoCvIbO6ndL5paUGtquanURwaYJESwefB9eP7a/hN5k8ozTom0Yy42W5v7T8 "Python 3 – Try It Online") - Python  
[Try it online!](https://tio.run/##PY5Bi8IwEIXv@ytmi2BS6ZD2GkMR9Oph2Vt1w4qxBkIsacR42b/enYh6mAfz5n0zE66H@xRAwZfpTRrQmxusV98rDOb3KMEqIeF2ts6AU72J4weAPYHrqnqvVLHzhaSB6wRi1ewlGH@kBDk4Ds5GNq/m/ImgM76PZ8aXDTEd8YS9kdMlgAfrIZsYL9qyWnDEHHy3lHvsYkUqSs9B/UGQ2bCf@c/hGsfHvvx3TX2wPoJ/nciaS@vNdq319MNYq3DRkrKUFi3fNeWMJBcv02yaRNUI8Q8 "Ruby – Try It Online") - Ruby  
[Try it online!](https://tio.run/##RY9Ra4QwEIT/SpAFE23E8/EkeNDn@wWehWD3aiC3kZhDOclvt9pS@jAD37AMs6Ob0U8DWruBV63HL1y685lw5pd0@@C8UUXe7M6XJW/Ercpgt0MiW2BLL2/Ju3uMxuJnImp4qbK@O4@6HzhYZoiBofEZxApagZXTaE1IZFKbOwdd9O5JQdrAquMgV6Dbsot7AQdSraHQ/SQ1kLT4x6eD81ysR4cvrjr0A048XdIMSPzGL7HO3gSUg5tC3Ged6n9mktz@oDWEDCjGuJWyKstv "PowerShell – Try It Online") - .NET
I finally found a use for the positive lookahead primality test I came up with on 2018-12-07! This is 2 bytes longer than the ["standard"](https://codegolf.stackexchange.com/questions/57617/is-this-number-a-prime/57618#57618) [negative lookahead primality test](https://codegolf.stackexchange.com/questions/57617/is-this-number-a-prime/177196#177196), but it allows the full regex to be 1 byte shorter:
```
^                           # tail = input number
(                           # Loop the following:
    (?=                     # Atomic lookahead - finds the first match, and once
                            # finished, its result won't be changed by backtracking
        .+?                 # tail = largest number that is less than the current tail,
                            #        for which the following matches:
        (?=(xx+?)\2*$)\2$   # Assert tail is prime; \2 = tail
    )
    \2                      # tail -= \2
)*                          # Iterate the above loop zero or more times
x$                          # Assert tail==1
```
A neat thing about this regex is that it can be logically negated for all inputs other than zero simply by adding one byte, because after the repeated subtraction, all \$n>0\$ end up at either \$1\$ or \$2\$:
```
^((?=.+?(?=(xx+?)\2*$)\2$)\2)*xx$
```
[Try it online!](https://tio.run/##TY87b8IwFIX/Co0Q3Js0JqCqA67J1IGFoR37kCy4JLc1jmUbSHn89jQMlTqcb/mOdHS@9EGHtWcX8@B4Q37X2G/66byydBy8UPXcOoCTWkzS7hOgVCIre0LbZiW@z9Jhj1swbdthl05OKGLzGj3bClAEw2uCx/v8AVEGVchjzYYAjPKkN4YtAeKdsntj8FwpI4IzHGGcj1HyFsCqShiyVaxxMbtcOKz0Clg57QMtbYTqrfhA/BP0X9jFtJzObxpj7ZtjsrQHbXgz8NpWNB8kmZHbxoPkJ0WSswz7waRNhCdHOgKj2Om4rsEjnsNo5PpLEW4vptLtY4i@r8jrtSvyWVH8Ag "JavaScript (SpiderMonkey) – Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##bVJdb9swDHzvr@CMDpGSVHX6ONUItmEDBqzb0D6mGaDYcqJUpj1JbpwW/e0Z5XgfBWLAlkmejroTt@pRXWyLh4OpmtoF2FIsTC3GEv7PtMHYkzmn17qjylnTrqzJIbfKe7hRBuEZhpwPKtDyWJsCKqqwu@AMrkG5tV8sOYSNq3cePnW5boKpaecZwGdjNZQZ6l3/yxKR14UWVE@4/NCWpXa6uNWq0A5WPex1kv3ZOYQl53Lo66dB7jaRnzGfrUiDKr4a1IzzNxm21nJTMi/0r1ZZz5LL8XiccP78GnpkYCycJHgmhvCXgQguiWFFuAfpJ9noHkdxDfLlmHv5oULQDsFlwx@prZrYwHNJbqzq2mqF8JSVxKgl3OUKkaQbbNoAGUS1Q47d7X3QlTDIJQw6e5jYKP9Nd4GO2VsMMBhi6ezEcQQhIQaJQ32xBEvliBK@sSaw5IIugfABMKXKFww0Bk40ynlNAbOLdMmngLOTRWE1rsPm@grmEJHwjpbZkhjzjXKLZTfo6SOcLSW8d07tvSiNtaybjrpRbwpAWbuojY6RYSoBrzOc0TKZkMAbFfINOVQRmxPVMWL95CIN@EciP06M2DnVsKFFXjf77@WtwrWmTukUOY9KS2AVtceCvIt3@8QHk2tybOdM0CxeKpdPWXBtvJ9/5YY8DCVL3vqELOHyJT5ncaoOPxmbZ2Iypy/rusmc31@Nz@kTXz7uuvNDHJ1DenGVpr8B "Java (JDK) – Try It Online") - Java  
[Try it online!](https://tio.run/##RU7LasMwEPyVJYhYG9u1bOilsmIH0mtPvTWpSEsMAjVxJRdUhPvr7toN9LDDzuxjpj87ez99fANzEqK9vp8ssEISVfV@97zbjtBdHWdeCVlvJUYwHTGMvTOXAVaHy0qO0Frle2sGnuRJ5r/e/EAnOsvLrMTz57zU/KuCdHxgGuX8y5PjybW2rjC29qU8KkJxlDdfc6PM1GoZU5emGE0HnCchgQC0hAjqBwrmCozMr9dLuCUbBS/lX1Zm5DiOWj8@7bWeXjlv1F3aEPIQ0gYP1YYRzIWbENg0ibwS4hc "Perl 5 – Try It Online") - Perl  
[Try it online!](https://tio.run/##XVBNa8MwDL33V4hgiNU4bdKra3LZBoWxw7Zb05ksc5pA6hgnhUDpb8/kstMOEvp4T0@Sa92yL1zrgHlQEG0j2IDz5qy9cX1VGx5vN@tC67bqJ10PF9f1xpe8RFm@b8dYQEzWUFGfTQDYydhp5Fq/HF6ftUYBOdJIGixXzeA561QmWa8ago/84/Pp8IYSb9A1nPXHcfK9sRRhmp@UikobIYHH6zd1qCwykeYY@GZ2/fBjeJRGguCS@PVwtVPg7ndEOtIA8tlJrgAeyvYvZ3avHn2KkgRJGvjj5Es11S1nXpBYuN9UE4/nWDCLiHALK3Zo6nYIe0mgU3IJIQdm5Z1k7v/@xFEuX5wXapMU5Pk8JwWWuzUjFwzX88yWJUt3WfYL "PHP – Try It Online") - PCRE  
[Try it online!](https://tio.run/##dVPbjpswEH3PV0zT1cYOkIWs1AcIG6lSf6DqQ6tsiljHAauJQcYoJNX@@qZjs6E0JZYweC5n5pwxrCy9jLHzRyHZrt5wWLwURaUfFM94M8vL8ml07eIN46UWhXzYiDSTaBIsEXJbqH1qzG0Wy1MFSblaQwxfx58Ph18vj/WP4/H7t/zTISfnn4Qs45mzxJ00jbOkz/PpHW7modOmuTvT66SxC9MyTkoniHpNCWxA8XT/NBJSwz4VklD4PQJc5QpdOy5JSb1gHfsR1BjzOE80FOZkEjLzUelNGGKskBkay1pHNp8VstJgWYehVQQUR7DoYquQMcvhkKfvGSgCEAN7in0XTrwDz7jeCcmJPTAh3bYOjS69mmUSpY@CpboQxAbMWIJ9EUpdkIELZVGhu/VshdyQiTehUQcgA/SamA9xn1MYSmNcDuCCY@MdCCiEWPwvlh3g1JST/NCeVjJwgnUEe76vuCaVC5NmYhpDRSp0Gom7/E4KEUuj9SKWQQSOI/qMzdLqeGWxWmyB9JVPKp4qlhPS40XvTVVPrF07AhenQ@kA1gXvRAGpGypk8ixROBxTEA2Gt3Mqag2LBYj/Y15Ht0/MXgryz@3pfhq450rRG4SHG7xqxmzjEL4oVahxNIzDKWwNkoVxDYCpGpkb2eGhpY83Nu/3bod/bGIxbhBvv9pdcV0rCXgZXs@@N/f9N7bdpVl19na2QGIn@gc "C++ (gcc) – Try It Online") - Boost  
[Try it online!](https://tio.run/##NY3dasMwDIXv8xTC9ELOj3G6uwSTB@k6KFu6arh2kDXmPn1md@xCB6HznaPtIbcYXna6b5EF0iP1vPZfKYYZ2LFSan9DXJzplqKYc7fo12N7KFJHtzkf9kKdxmkYzzOQs801MnigUNtMkg8KUwPeeZM2T4JqULqBCoUK8SV8rkhB0J/sWfd/WynT3ahLEOgKvJr7Rd5vyD2orNrwNKpDE2xcI/p5cOP8/zV@i/lhkhWTMAatdzscrf0F "Python 3 – Try It Online") - Python  
[Try it online!](https://tio.run/##PY5Bi8IwEIXv@ytmi2BS6ZD2GkMR9Oph2Vt1w4qxBkIsacR42b/enYh6mAfz5n0zE66H@xRAwZfpTRrQmxusV98rDOb3KMEqIeF2ts6AU72J4weAPYHrqnqvVLHzhaSB6wRi1ewlGH@kBDk4Ds5GNq/m/ImgM76PZ8aXDTEd8YS9kdMlgAfrIZsYL9qyWnDEHHy3lHvsYkUqSs9B/UGQ2bCf@c/hGsfHvvx3TX2wPoJ/nciaS@vNdq319MNYq3DRkrKUFi3fNeWMJBcvU5pNk6gaIf4B "Ruby – Try It Online") - Ruby  
[Try it online!](https://tio.run/##RY9Ra4QwEIT/SpAFE20k5@NJ8KDP9ws8C2L3aiC3kZjDcOJvt9pS@jAD37AMs6Ob0U8DWruB143HL4zt@Uw480u6fXBe6yKvd@cx5rW4lRnsdkhkMcKWXt6Sd/cYjcXPRFTw0qq6O49dP3CwzBADQ@MziAU6DVZOozUhkUll7hy6ondPCtIGVh4HuYauUe26F3Ag3RgK7U9SAUmLf3w6OM/FcnT44tqFfsCJpzHNgMRv/BLL7E1AObgprPusU/XPTJLbP7SGkAGt67opWSr1DQ "PowerShell – Try It Online") - .NET
---
Here is the regex implemented in some languages that have golf-efficient regex calls, where it either beats the other submitted solution(s) or is the only one in that language:
### \$\large\textit{Anonymous functions}\$
# [Julia](http://julialang.org/) v0.4+, 58 bytes
```
n->split("x"^n,r"^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$")[1]==""
```
[Try it online!](https://tio.run/##TY3BbsIwDIbvewov4pAAnWiPy7KeeYYNpCASyGSZKkmlqC9fnBUkDv5l@/f/@W/EYNsyezNT850GDFmKIo60jeIoZW8@Nj2rLGXTq99uvWKppdZlJdRPezBGiHky3mJyGvwtAkIgiM6eMZBLUr0BoFnIuBWNUBqCB3R0yVeJ6qvTMIzp@s4uMpBtR2cOVRZV1mBjcnJPefE/X@fuUPlQiV7S0gNc8HayCJPm9aSHGCgjSaUZrGEyOY7ucfnvPYPL36pcc9t0u90d "Julia 1.0 – Try It Online")
The above returns truthy for an input of `0`. If returning falsey for `0` were needed, it'd be **60 bytes**:
```
n->match(r"^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$","x"^n)!=nothing
```
[Try it online!](https://tio.run/##TY3BTsMwDIbvPIUX7eBsK@p6XAg98wywSYElbZBxqySVqr58SShIHPzL9u//8@dE3pzn1emVq@cvkz56DOKG2OrHY5sV5/nYyrfmsM9SSh7mvTiJWdxY7jQPqffcrYt2hqJV4IYABJ4hWHMnzzaifAAgHUfyCekkKiEVeAdkuUs9knxqFIxT7HfZpdfzNduW7zlUWFxYownR4gunzb/8n5tr4UMhOuStB@hoeDcEi8rrRY3BcyJGqTJYwaJTmOzv5Y/3F9z@Fs211lVT198 "Julia 1.0 – Try It Online")
or **59 bytes** in Julia v0.7 and earlier with `!=Void()`: [Try it online!](https://tio.run/##TY3BTsMwDIbvPIUX7eBsKyq9IBFCz7wAF9ikQJM1yLhVkkpVX74kFCQO/mX79//5cyJv7lenV66evkz66DGIC2Krb49tVpznYyvfmsM@Syl5mPfiJGZxYbnTL4PvUK6LdoaiVeCGAASeIVjTkWcbUd4AkI4j@YR0EpWQCrwDsnxNPZJ8bBSMU@x32aXXu3O2LXc5VFhcWKMJ0eIzp81/@D8358KHQnTIWw9wpeHdECwqrxc1Bs@JGKXKYAWLTmGyv5c/3l9w@1s011pXTV1/Aw "Julia 0.7 – Try It Online")
Of course as far as Julia v0.4 goes, [Glen O's answer](https://codegolf.stackexchange.com/a/92937/17216) outgolfs this at 32 bytes, but for v0.5 and later, this and the below may be optimal golf.
# [Julia](http://julialang.org/) v0.7+, 54 bytes
```
n->occursin(r"^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$",'x'^n)
```
[Try it online!](https://tio.run/##TY3RbsIwDEXf9xVehYQDFJU@Lsv6vG/YQMoggUyWWyWpFPXnu4SCtAdf2b6@x78jOX1Is1Uz1x/9@Tz64Bh9dULs1H7bZcWUtp34bjerLKXEJq2q3TqtTyzmSVlNwUiwvQcCx@CNvpBjE1C8AJAKA7mItKvqSkhwFsjwNd6QxHsrYRjD7TW79HU4ZtvwJYcKiwtr0D4Y/OS4@G//5/ZY@FCIFnnpAa7U/2iCSeb1JAfvOBKjkBksYVLRj@ZxefeeweVv0VxzU7dN8wc "Julia 1.0 – Try It Online")
# [Julia](https://julialang.org) v1.2+, 53 bytes
```
n->endswith('x'^n,r"^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x")
```
[Attempt This Online!](https://ato.pxeger.com/run?1=TY_BSgMxEIbvPsW4CE3arqwLghjjnn0GbSHSpI0M0yXJ4rKv4qUI-0ZefBsnpoKH-cnkz__N5GN-G9Cb06fT85Bcffd9S_WjpV189-kgFuNiS-tQbYXo9PWqYxXjuOrkS7u8Yskll2Mlz-GvSTuD0SpwxwAIniBYs0NPNgp5AYA69uiTwHVVV1KBd4CW9jwK5UOroB_i4ZJdfL7ZsM2LcCizKLN6E6IVT5SKf_-_bzeZD5noBJUzwB6PrwZhUnw9qT54SkhCKgYrmHQKgz2__PX-gmVuVq7yt9Pc1G3TlOYH "Julia 1.7.3+ – Attempt This Online")
# PowerShell, ~~52~~ 51 bytes
```
'x'*"$args"-match'^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$'
```
[Try it online!](https://tio.run/##RY5dCoMwEISvEmSpiSEl9TUED9IfCBJrIN2IRpRKzm5jofRhh/2WmWGHsNhx6q33O3R628u1rAow43MqxMvEti8flDb6zJusdF15w251BVmOYdUK5Z4UvLVUXRitaXsKnjgk4HCYI9vAaPBiGryLhSiU6yiYcxtmjMJHUh8GrsFc5T3lAgqorw7j/XtRgMLbH18O5pxtueMEHQH8rvBm2zK6aEUfppjyKxf1ZyIwoF28Q5sDKaVdilrKDw "PowerShell – Try It Online")
*-1 bytes thanks to Julian*
# [Python](https://docs.python.org/), ~~70~~ 69 bytes
```
lambda n:re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*n);import re
```
[Try it online!](https://tio.run/##LYzLCoMwEEX3fsVQhCS@iC6V4IdUF7ZqDcRRkiyiP2@T2sVczoUzdz/ssmF1yXXftAVzmAZOwRuYRXepYX2NA2Ctp2Id7HuhmlDaiiJtfVLn0pZ1VRL7CMcSF5OMOJIga/6DerrmTYMCiWG8MHaUWEeghCrMrqSlj/zBIggSBkkP@JmoREvVk/csuykve5aWzD@CnGGm@MPAZw279lKopyibu4Gx2kvZxfOK8y8 "Python 2 – Try It Online")
# [Python](https://docs.python.org/), 73 bytes
```
lambda n:__import__('re').match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*n)
```
[Try it online!](https://tio.run/##JY1LDoMwDET3nMKqkGLzU2AJQhykrRD9UCIFg5IsKJenSVl45LGeZ9avmxauDjWvi3Fgv7aBvZXRuBjQoDhcCuteiusIdKsLu2rl8JJfKIIAcYDMwJ83Knaor/JO2bnl5Z3SkvwjqBHw0MP8eA3Add@fdX2PwrwFFfPgnhMagdi1Rdp5xW1LO7pVSewlDCVbLDKxiYTpACDkf3BI3mtYja8Mdm/L5nRgnfFQdsi8kvIH "Python 2 – Try It Online")
(If it must be a pure lambda.)
# JavaScript (ES6), ~~58~~ 54 bytes
```
n=>/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/.test(Array(n+1))
```
[Try it online!](https://tio.run/##TY3NbsIwEIRfhSIEu0QxCb1hnKhHLrxAfySLbJItrmPZBoSAZ0/NoVIP883hk2a@9VmHg2cX8@C4If8z2CNdx1aNVlWrL4BaiaxOBJEaP9bLWcIzuBSzlYgUIrx5r69gsxJxDKqQl54NARjlSTeGLQHii7InY/DWKSOCMxxhkS9QcgtgVScM2S72WK3vdw57vQdWTvtAOxuhey8@Ef8E/Re2Kuty89QYez9cpjt71oabide2o81kmhnZDh4kbxVJzjJMhy0w4i3M585zWkEZVCndKYbok5GPx1jkr0XxCw "JavaScript (SpiderMonkey) – Try It Online")
*-4 bytes thanks to a technique used by [RK.](https://codegolf.stackexchange.com/a/58174/17216) and [CubeyTheCube](https://codegolf.stackexchange.com/a/220521/17216)*
# [Perl](https://www.perl.org/), ~~49~~ 47 bytes
*-2 bytes [thanks](https://codegolf.stackexchange.com/questions/85/fibonacci-function-or-sequence?page=1&tab=modifieddesc#comment546580_223243) to dingledooper*
```
sub{1x pop~~/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/}
```
[Try it online!](https://tio.run/##PYvLDsIgFER/5S5uKrTaV@JGRH/EmFRD9SZCCWBsY@qvI3XhYubMWYxV7rGNT6/AB0fXIGDZr84ZMjcvwAx/gZUarXKklQndY7fzunNBd@F6XwnQE2Avo39e3s0IdrCfT3Vm7CjL4pialYn81OaYagnPS6zmKPrBMT2hl/U6gWQtkPayrRcWBX8D9Qz7zYEh8WTos8w6MgErkU6NgJ8BEswwxy8 "Perl 5 – Try It Online")
This beats a port of [Ton Hospel's **41 byte** answer](https://codegolf.stackexchange.com/a/93003/17216) (**57 bytes**):
```
sub{my$x=1x pop;$x=$`while$x=~/\B(?!(11+)\1+$|$)|11$/;$x}
```
[Try it online!](https://tio.run/##HYtbCoMwFAW3cgsXSUiLptCvNC10HX70gWkvaAyJoqJ262ns18zAOa7y9Sn2oYLQeXp1CjYfHt6SfQcFzQRodAz9c24mHLUcwbVOJcP78KG6SvbNyxu77piUgpdS4IJ8kRLztFqjMq1n6Rp0sU8gXSiksz4WG4XgM5BhaA4XhsRTYcgy58l22z9oqeBfgAQrrPEH "Perl 5 – Try It Online")
Even if it's allowed to modified the global variable `$_` (**51 bytes**):
```
sub{$_=1x pop;$_=$`while/\B(?!(11+)\1+$|$)|11$/;$_}
```
[Try it online!](https://tio.run/##HYvbCsIwEAV/ZYWlJERpV/ApRsHvELzR6EIvIWmppe23x9SnmYFzXOmrQ@xDCaHz/Oo0rD48fMPNO2ioR0BrYuifE94MfcG1TifD@/DhqsyvF3HeCCIlr6RwRjkTYZ4WS9S29aIeMZhim8Cm0MhHsy9WKiUnYCvQ7k4CWabCkGXOc9Ot/2BIw78AGRZY4g8 "Perl 5 – Try It Online")
# [Ruby](https://www.ruby-lang.org/), ~~48~~ 45 bytes
```
->n{?x*n=~/^((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$/}
```
[Try it online!](https://tio.run/##PY7NDoIwEITvPsVqSGwhLYUrVh4E0MTIT5NmMVAixuir49Yoh510p/NNdpguj6XRizjiM59D1O/4xFiuZZSTsnmOcl6mYUDih4dzEL8Wo1UG987YGqxuazduAEwDthBJpfWuxF1GH7ZQUoq0yqDGKyXIkePNGsf2Ys9/iLQ1tq5j/JASUxBP2Io0/QAIBsGb0vVnwxLFpfTBdaXct6spkEB6mK2/7za58dtDnk5oHww6wH@1V5pFiVSpDw "Ruby – Try It Online")
*-2 bytes by switching the truthy value from "string of `x` characters whose length is the input number" to "the integer value `0`", while keeping the same falsey value of `nil`*  
*-1 byte by using `?x` instead of `"x"`*
# [PHP](https://php.net/), ~~89~~ ~~75~~ 71 bytes
```
fn($n)=>preg_match('/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/',str_pad('',$n))
```
[Try it online!](https://tio.run/##LY89b4MwEIb3/AoLncRd@IhhNS5Lly5d2i1Jo5TYAck1FhCpUpTfTs9RB7/n@3j8nkMf1qYNfRBg9Wo9gif9EiZzPf2cl67HdPeF2Ooya1mx5EiHegss8dC2hF2az8t0CucLpmnOPK1qY8cJYdBSgdP2apYZPz5f395J0V0MFsHtmXGG/RwV1VHr5OAT4uH59s0dLucyLyqKvPkNbrwYTIok53HFfDfe/BLZpmZozw@wyqPaCPF09v85@EY/@3zLMmJrgWDjJ0nc4x4Dma4fo7kSvG@lRMwFePV4rLKopfwD "PHP – Try It Online")
*-4 bytes by switching from `x` to  as the repeated character*
# [R](https://www.r-project.org/), ~~73~~ ~~72~~ ~~68~~ 63 bytes
```
\(n)grepl('^((?=.+?(?=(..+?)\\2*$)\\2$)\\2)*.$',strrep(1,n),,1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LU5BasMwELz3FYsJeDeRje1TqRD-QO492C6YRnIFQjVa5ZKQl_SSFvKEPqa_qdT0MrvD7Mzsx2e4fhl1O0ZTPf70I3pagl4dli-Ivap3fUKs06Rx7LabjH9A23pTCo4hXWMrPAnR0n_MN6tGwkkZ6zQWHA_WFyTBvAd0YD3wcV2DZn6eg7d-YQx6Puyt14wnIjo_ADhQkMJ5dTaiE1BUBQ1DO00SrAF02i_xDR0p1RK4oZuUS2oy5hKbSzJ_ygolBxq0RHBOG9PrHLEcfUmSVSshU0uXy_35662puqa5k18) / [Try it online!](https://tio.run/##PU3LboMwELznK7YoErupQcARauUHeu8BqJQmNrFiOcjrqioR307tSu1ldkfz8pt@KbbZf/u21Th5NVvM3xGPsnw@RsQyXhqG5rBP@At0KPe54OCjG2vhSIiaaGNZdbBIbazCjMPFuIx2X9dEa3rsACxI4M959or57eSdcROjV6fLq3GKcRHgZCzqwGh8sspN4YqWCB5ne2eFS1Q@ov22/nUFz7M1Aa2ArMio7@txTGnA/7SMjWD7ZpQ2qjGo7x4NGAeJt0mhtKfRpKX4MZ1PAfPB5dSxrDtI1NC6blXRVNUP "R – Try It Online")
```
\(n)grepl('^((?=.+?(?!(..+)\\2+$)(..+))\\3)*.$',strrep(1,n),,1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LY5BasMwEEX3PcXUBDwTy8ZyNyVG-ALdd2G7YBrJFQjVaJRNQk7STVrIEXqY3qZy0937_Pn_z8dnuHwZdT1EUz7-dAN6moNeHOYviJ2qig67e6yqgoahKTb0h4kfaFttcsExpGuUwpMQkv5rvlnVLRyVsU5jxnFvfUYtmPeADqwHPixL0MzPU_DWz4xBT_sn6zXjkYhOdwAOFKRyXpyN6ARkZUZ9L8exBWsAnfZzfENHSkkC1zejcslNwXXEriOr3q0OpQQatERwSsT0OkXMB59Ty0q2sEpL5_Pt-cu1Lpu6volf) / [Try it online!](https://tio.run/##PY3NaoQwFIX38xR3ZMB7axR1dtrgC3TfhVqwM4kTGjKSpJQ6@Ow2KbS783H@7C6f832x37ZpJM5WLBrTN8SOF1mH3RGLIqNhqLMT/cqgz/RUnFLmvA1prJghxiqi3fGyhZVLpQUmzl@VSejwdYtY0eMAoIGD@1wWK5x7naxRZnZoxXR9UUY4XBkYHoZaUBKPWpjZ31ATweOi707gGpz3EP/Y/ra8dYtWHjWDJE@o76txjG3A/zYPi6D7euQ6uKEo7xYVKAORm@hQ/JOo4lNQji6Tx3QwKbWOVy1EVLRte5nXZfkD "R – Try It Online")
*-1 byte [thanks to Giuseppe](https://codegolf.stackexchange.com/questions/248690/is-it-a-valid-list/248747#comment555846_248747)*  
*-4 bytes by using `grepl()` instead of `sum(grep())` or `any(grep())`*  
*-5 bytes by using a new anonymous function syntax introduced in R v4.1.0*
Since TIO uses R v3.5.2, the TIO links have the old **68 byte** versions of the function.
# Java 8, ~~92~~ ~~89~~ ~~88~~ 71 bytes
```
n->new String(new char[n]).matches("((?=.+?(?=(..+?)\\2*$)\\2$)\\2)*.")
```
[Try it online!](https://tio.run/##bVBNb9swDL33VxBGh1D5EJwcp7jBehgwYNslx8QH1ZVjpQptSHLzMey3Z7SdtodOB1LUe3zi416/6tn@@eVqD03tI@y5lm20TpYtFdHWJMcKPoFjdVc4HQL80pbgzx1A0z45W0CIOnJ6re0zHBjDdfSWdpsctN8F0VMBvt@0lz8omp3x08e6dkbTA5SQXWn2QOYIQyd216LSfkO5kAcdi8oETBBXmZysOKLkLLbbxfi@i30QY5mIq@K/ngZhuGSldsEoWBeayHiw1LQRMuh/Gt5wfQ7RHKQloeBYWWcAe5qsdPhtThHFm4FhNnCWDGsMJGLGT35A7n537RjuWDI0zkZMZgmjliJQysjNvmy0D4YLdJs0F1Og@X9B6QztYrVcwAo6JnzlNM9ZsV9Qfrr5GdY1zxV8816fgyytc3iajk4jofr5y9p33niMjFIFtMxozmkyYYO2BCylbhp3RhKCa7yI22pq9nn0NhocbYnFLln0bbfVD7hh57HE5EtI2IhQf7tzTWeLNP0H "Java (JDK) – Try It Online")
```
n->new String(new char[n]).matches("((?=.+?(?!(..+)\\2+$)(..+))\\3)*.")
```
[Try it online!](https://tio.run/##bVBNk9MwDL3vrxAZmMpN60nLDTfbgQMzzACXHtscvFmncXGVjO1sPxh@e1dJChzAF0l@T096OugXPT88/7jZY9v4CAeuZRetk1VHZbQNyamCf8CpeiidDgG@aUvw8wGg7Z6cLSFEHTm8NPYZjozhJnpL@20B2u@DGKgAn@/aqy8Uzd742aemcUbTI1SQ32j@SOYEYyf2aVlrv6VCyKOOZW0CJojrXKZrXL9BKVOx2y3Tt2JIOX8vpjIRN8WznkZhuOaVdsEo2JSayHiw1HYRchgmjX@4uYRojtKSUHCqrTOAA03WOnw354jit4FxN3CWDGuMJGLGV/5A7v7j2jHcs2RonY2YzBNGLUWgjJG7fdlqHwwX6LZZIWZAi/@C0hnax3q1hDX0TPjAYVGw4nCg4nz3M55rUSj46L2@BFlZ5/A8m5wnQg37V43vvfEaOWUKaJXTgkOaskFbAVZSt627IAnBNV7F/TQN@zx5Gw1OdsRi1zz6rr/qX7hl57HC5F1I2IhQv/p3y@bLLHsF "Java (JDK) – Try It Online")
*-17 bytes by just matching the regex straight against a string of NUL characters instead of replacing the NULs with `x`*
# Java 11, 61 bytes
```
n->"x".repeat(n).matches("((?=.+?(?=(xx+?)\\2*$)\\2$)\\2)*x")
```
[Try it online!](https://tio.run/##bVDLbtswELznKxZCA5N@ELKPpRUjORQokPTio60Do1AWHXolkKtYdtFvd1ey0x5aHnYxnOFwZ/fmw8z2b@8Xd2jqQLBnrFpyXpUtFuRqVGMN/5BjfVd4EyO8GIfw8w6gaV@9KyCSIW4ftXuDA3NiTcHhbpODCbsoBynAt5v38juS3dkwfaprbw0@QAnZBWcPSZeoYBtrSKBUB0NFZaNIhFhlarLiKhR3ud0uxl/6OhQ5Vom8aP7h9WoH56w0PloN68Ig2gAOm5YgA7THzzuxPkWyB@VQajhWzlsQg0xVJv6wHQn5OfY1C3iHlj2uImTFM18Ifv0nq2e6V6nYeEcimSXMOiTAlJlbaNWYEC0D4TdpLqeA8/@SylvcUbVcwAp6JXzlNs/ZsahM2OTdLc@AcJ5reAzBnKIqnfeim466kdTD/GUd@mw8RoapBlxmOOc2mXBAV4IolWkaf@KVS8biLG@rqTnnMTiyYrRFNjtnFNp@q3/phpNTKZL7mHAQqX/155LOFmn6Gw "Java (JDK) – Try It Online")
*-10 bytes relative to Java <11, [thanks to Kevin Cruijssen](https://codegolf.stackexchange.com/questions/138011/is-it-a-semiprime?answertab=votes#comment547728_138086)*
### \$\large\textit{Full programs}\$
# [Python 2](https://docs.python.org/2/), 69 bytes
```
import re
re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*input()).re
```
Outputs [via its exit code](https://codegolf.meta.stackexchange.com/a/5330/53748), value `0` for truthy (by exiting normally), and `1` for falsey (by triggering an `AttributeError`).
[Try it online!](https://tio.run/##K6gsycjPM/r/PzO3IL@oRKEolasoVS83sSQ5Q6NIXUPD3lZP2x5IalRUaNtrxhhpqQAJENbUqlBR11GvUNfKzCsoLdHQ1NQrSv3/39AYAA "Python 2 – Try It Online")
# [Python 2](https://docs.python.org/2/), ~~71~~ 70 bytes
```
import re
re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*xx$','x'*input()).re
```
Outputs [via its exit code](https://codegolf.meta.stackexchange.com/a/5330/53748), value `1` for truthy and `0` for falsey, using the truth-inverted regex.
[Try it online!](https://tio.run/##K6gsycjPM/r/PzO3IL@oRKEolasoVS83sSQ5Q6NIXUPD3lZP2x5IalRUaNtrxhhpqQAJENbUqqhQUddRr1DXyswrKC3R0NTUK0r9/9/QAAA "Python 2 – Try It Online")
Alternative method using the uninverted regex, outputting exit code `1` for truthy (by triggering a `NameError`), and `0` for falsey (by exiting normally), at **71 bytes**:
```
import re
if re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*input()):z
```
[Try it online!](https://tio.run/##K6gsycjPM/r/PzO3IL@oRKEolSszDUjq5SaWJGdoFKlraNjb6mnbA0mNigpte80YIy0VIAHCmloVKuo66hXqWpl5BaUlGpqaVlX//xsaAAA "Python 2 – Try It Online")
# [Python 2](https://docs.python.org/2/), ~~79~~ 74 bytes
```
import re
print re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*input())>0
```
Outputs `True` or `False` via stdout.
[Try it online!](https://tio.run/##K6gsycjPM/r/PzO3IL@oRKEolaugKDMPxNDLTSxJztAoUtfQsLfV07YHkhoVFdr2mjFGWipAAoQ1tSpU1HXUK9S1MvMKSks0NDXtDP7/NzQAAA "Python 2 – Try It Online")
# [Python 3](https://docs.python.org/3/), ~~84~~ 83 bytes
```
import re
print(not re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*xx$','x'*int(input())))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PzO3IL@oRKEolaugKDOvRCMvH8TRy00sSc7QKFLX0LC31dO2B5IaFRXa9poxRloqQAKENbUqKlTUddQr1LVAGjPzCkpLNDSB4P9/QwMA "Python 3 – Try It Online")
The above uses the truth-inverted regex. Without it is **84 bytes**:
```
import re
print(bool(re.match(r'((?=.+?(?=(xx+?)\2*$)\2$)\2)*x$','x'*int(input()))))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PzO3IL@oRKEolaugKDOvRCMpPz9HoyhVLzexJDlDo0hdQ8PeVk/bHkhqVFRo22vGGGmpAAkQ1tSqUFHXUa9Q1wJpzMwrKC3R0ASB//8NDQA "Python 3 – Try It Online")
# [PHP](https://php.net/) `-F`, 70 bytes
```
<?=preg_match('/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/',str_pad('',$argn));
```
[Try it online!](https://tio.run/##VVDLbsIwEDyXr5i6Lk5CQ1I4OoEbUk8ceoQWhdghVoMdmUitaPj21OEhVEs7qx1Ls7OzzQ5lZ2UmEFoBxmCThG2uj3XJPK2t3G32WZOXHos@PW@ejkdzh97YdX89CaiDvvxgTCP2cmjsps6Ex9gLzexO@z7vboIDmZcGoQahlrB@IGtNOMMMuRGSQ/7IHNPZ8JVj/1WowmDJ8V2qSuJt8Z7i6hRV264uOhXBBxcGhbHwPOiU0N/qmYQkOBEOnZznp8ARJwJHjEZwjoQZPJy9UM3/K2dIsETbOiuq4VAFVqCZ2yURu01NKfWFfER4BD3euF5tNpzyQnEcU@f/fqom/QcKNRBGuyN7RIvI1E1Ul3W0VbrvCBfnFFwYy3sSYReHkzj@Aw "Bash – Try It Online")
# [Perl](https://www.perl.org/) `-p`, ~~45~~ 43 bytes
*-2 bytes [thanks](https://codegolf.stackexchange.com/questions/85/fibonacci-function-or-sequence?page=1&tab=modifieddesc#comment546580_223243) to dingledooper*
```
$_=1x$_~~/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/
```
[Try it online!](https://tio.run/##LY3RbsIgGIVfhZg/FuxaqYk3MqbvMbemUzpJyg8Bmmmb@ujraLKLc76T7@Y45bv93AdF9iWvuCBoyU/jUeN3IJm6O@W1URib7nAIpvHRNPFyywQxD2hl6L9GqKWzTsyJ1R3q53P7SelRlvkxNS0T2Xm3gVRL2KaE7SygngQJsYmKwCAuN2ucMI9TJ4PrdKRZkb1AzQRprafpCeWpe@cfAvB1WUW1zDxno24ptMUbBWRshGG9dl5jXJ1xJWCQlSBQ/zsCOE2kx6tqk5x5seP817qoLYa5cH8 "Perl 5 – Try It Online")
Beaten by [Ton Hospel's **41 byte** answer](https://codegolf.stackexchange.com/a/93003/17216) which mixes regex and code: [Try it online!](https://tio.run/##LY3RaoMwGEZfJSs/NcG6JoPeNLMre405nO3iDCR/QhJpq/XV5yzs6hwOH3xeBbOb@6jI7pkLLgk6cmkCavyJJFNXr4K2ClNj9vtom5Bsk85dJom9QVvG/jRCXXrn5bxQXKGWC@Hr0mmjttU7fXuiQuSsEjncgd2FgO28TCZJYmqSIjDIc@esl/Z2NGX0RieaFdkGaiZJ6wJdfrA8mg/@KQFfH1aIh@Y5G3VLoS0OFJCxEYb12geNaVXhSsJQCkmg/m8EcJpIj9@qXeLMixfOf51P2mGcC/8H "Perl 5 – Try It Online")
# [Perl](https://www.perl.org/), ~~46~~ 44 bytes
```
say 1x<>~~/^((?=.+?(?=(..+?)\2*$)\2$)\2)*.$/
```
[Try it online!](https://tio.run/##FY7ZSsNQFADf5ysiFJpUTO9ZbhZc@gX@gQhBrrTQjSRiReynG@PDzLzOOfX7OH0MKUuXc@p3h3Qcu322HA5dPx668W27vP/c7vYpv0mn97wovqeh@8rk8vB0va5f83zzWN5uZufl3OJFV4tZ/xSrcrGefibDqWiQgAiiiCMVUiMNGlBFDXW0Qmu0xQKmmGMRq7EGD7jgijte4TXeEAORmhYxJCItKmhEG0wwwyqsxeeBiLe/p/O4Ox2H6e45lkHCHw "Perl 5 – Try It Online")
Now beats a port of Ton Hospel's answer (**45 bytes**):
```
$_=1x<>;$_=$`while/\B(?!(11+)\1+$|$)|11$/;say
```
[Try it online!](https://tio.run/##Hc7LSgNBEEbh/XmLQC9mCJr@q6rnQryAe98goC5GDAQnJAEV46vbBldn8W3OfjrsSv142@6mZjHNr03bftf0dKvPm7v1pen531abh@Z@0UjLdqNlOqf2LKXV@vjyVX@qE3QMKCMhQ4E61KMBy5hhjgXWYT024hk3PPCC9/hAZEKEEUF0RE8MlEyhZ0SOChoxYQUbcOGOd/hIXAYKMf7O@9N2fj/Wq8dynZX/AA "Perl 5 – Try It Online")
[Answer]
# Pyth, ~~18~~ ~~15~~ 14 bytes
*Thanks to @Maltysen for -1 byte*
```
#=-QefP_TUQ)q1
```
A program that takes input on STDIN and prints `True` or `False` as appropriate.
[Try it online](https://pyth.herokuapp.com/?code=%23%3D-QefP_TUQ%29q1&debug=0)
**How it works**
```
#=-QefP_TUQ)q1  Program. Input: Q
#          )    Loop until error statement (which occurs when Q<3):
         UQ      Yield [0, 1, 2, 3, ..., Q-1]
     fP_T        Filter that by primality
    e            Yield the last element of that
 =-Q             Q = Q - that
            q1  Q is 1 (implicit variable fill)
                Implicitly print
```
**Old version with reduce, 18 bytes**
```
qu-G*<HGH_fP_TSQQ1
```
[Try it online](https://pyth.herokuapp.com/?code=qu-G%2a%3CHGH_fP_TSQQ1&debug=0)
**How it works**
```
qu-G*<HGH_fP_TSQQ1  Program. Input: Q
              SQ    Yield [1, 2, 3, ..., Q]
          fP_T      Filter that by primality
         _          Reverse it
 u                  Reduce it:
                Q    with base case Q and
                     function G, H -> 
     <HG              H<G
    *   H             *H (yields H if H<G, else 0)
  -G                  Subtract that from G
q                1  The result of that is 1
                    Implicitly print
```
[Answer]
# JavaScript (ES6), ~~64~~ 63 bytes
*Saved 1 byte thanks to @Neil*
```
g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))
```
I wrote this in 2 minutes... *and it worked perfectly the first time.* First user to find the inevitable bug wins....
### Try it out
```
g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))
```
```
<input type="number" value=3 min=3 onchange="A.innerHTML=f(this.value)"><br>
<p id=A>1</p>
```
### How it works
First we define **g(x)** as the function that finds the first prime number **p <= x**. This is done using the following process:
1. Start with **n = x-1**.
2. If **n < 2**, **x** is prime; return **x**.
3. If **x** is divisible by **n**, decrement **x** and go to step 1.
4. Otherwise, decrement **n** and go to step 2.
The solution to this challenge, **f(x)**, is now fairly straightforward:
1. If **x < 3**, return **x = 1**.
2. Otherwise, subtract **g(x-1)** and try again.
[Answer]
# Julia (0.4), 32 bytes
(Update (as of 1.4): This is rather out-of-date, now - `primes` is no longer in Base, and `?:` needs spaces around the `?` and the `:`)
While it's not going to be the shortest solution among the languages, this might be the shortest of the human-readable ones...
```
!n=n>2?!(n-primes(n-1)[end]):n<2
```
[Try it online!](https://tio.run/##TY4xDoMwDEX3nsJhSqQiQUZC2rlnQAxIhJLKdVESFi5PHejQwda3/vezXyv6Yd8FWbrpu5BULsG/XWRRq87R2KuGWr1vdhowOgPTJwCCJwhuGNETR9UFAG1c0CeJ16IslAE/ATp6plmiarWBZY2zYBe7umebwbyUWZRZyxCikw9Kp9/8z7rPfMhEQYc69Gb4UUpIUhmmGdhsCqv7BQ5P0rl5Hsuda69LXVVf "Julia 0.4 – Try It Online")
Or, to put it in slightly clearer terms
```
function !(n)
  if n>2
    m=primes(n-1)[end]   # Gets largest prime less than n
    return !(n-m)        # Recurses
  else
    return n<2           # Gives true if n is 1 and false if n is 2
  end
end
```
Called with, for example, `!37`.
[Answer]
## Pyke, ~~15~~ 11 bytes
```
WDU#_P)e-Dt
```
[Try it here!](http://pyke.catbus.co.uk/?code=WDU%23_P%29e-Dt&input=49)
```
            - stack = input
W           - while continue:
  U#_P)     -     filter(is_prime, range(stack))
       e    -    ^[-1]
 D      -   -   stack-^
         Dt -  continue = ^ != 1
```
Returns `1` if true and raises an exception if false
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~11~~ 9 bytes
```
εωλ-→fṗŀ¹
```
[Try it online!](https://tio.run/##Dc67CcJQGIDRhT7h/o/7miWklYCkEnu1EGxtnEQh2AVs4wxmkatngjMc9rs2P8dxPZ/a8vhcl9dmvdy23@n@Ps5Ta63rDCdRkIAIoogjCclIQQOqqKGOJjSjFQuYYo5FLGMFD7jgijue8IwXYujpIpmKGBKRigoa0YIJZljCKv4vRLz2/Q8 "Husk – Try It Online")
-2 bytes from Leo.
None of the testcases reach zero because the max number we can subtract from `n` can only be `n-1`. Hence, we can check insignificance instead of equality with 1.
## Explanation
```
εωλ-→fṗŀ¹
 ωλ       iterate on the input till fixpoint
       ŀ¹  range 0..n-1
     fṗ    filter out nonprimes
    →      last element
   -       subtract from n
ε         is fixed point insignificant? (<= 1?) 
```
[Answer]
# Python3, 102 92 90 89 88 bytes
```
f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])
```
Golfing suggestions welcome! I see that `gmpy` contains a function `next_prime`, but I can't test it yet :(
-2 bytes, thanks to [@JonathanAllan](https://codegolf.stackexchange.com/users/53748/jonathan-allan)!
-1 byte, thanks to [@Aaron](https://codegolf.stackexchange.com/users/42652/aaron)!
## Testcases
```
f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])
s="3 4 6 8 10 11 12 14 16 17 18 20 22"
h="5 7 9 13 15 19 21 25 28 31 33 36 39"
for j in s.split(" "):print(f(int(j)))
for j in h.split(" "):print(f(int(j)))
```
Output is 13 truthy values and 13 falsey values.
`s` contains the truthy cases and `h` the falseys.
[Answer]
# [Haskell](https://www.haskell.org/), ~~65~~ 63 bytes
```
f n|n>2=f$n-last[p|p<-[2..n-1],all((>0).mod p)[2..p-1]]|1>0=n<2
```
[Try it online!](https://tio.run/##Pc2xCsMgFIXhV7lDB4UoJl2jU8e@QcggNLa3NVfR26GQd7cpgW6HjwP/w9fXEmPDNafCcPHs9RUrg8i@MDImkqAUPN@7hVQgFyRGurcAtJEbbDiRir7ylLc8qmnQmlQ/dz5GIZyRek03yPLnefd5652xNA5t9Ug2Liw@S@0oSfsPQpjOWvfGzEhHD/aPc8ek1L4 "Haskell – Try It Online")
[Answer]
## Mathematica, 32 bytes
```
2>(#//.x_/;x>2:>x+NextPrime@-x)&
```
This is an unnamed function which takes an integer and returns a boolean.
### Explanation
There's a lot of syntax and funny reading order here, so...
```
   #                               This is simply the argument of the function.
    //.                            This is the 'ReplaceRepeated' operator, which applies
                                   a substitution until the its left-hand argument stops
                                   changing.
       x_/;x>2                     The substitution pattern. Matches any expression x as
                                   long as that expression is greater than 2.
              :>                   Replace that with...
                  NextPrime@-x     Mathematica has a NextPrime built-in but no
                                   PreviousPrime built-in. Conveniently, NextPrime
                                   works with negative inputs and then gives you the 
                                   next "negative prime" which is basically a
                                   PreviousPrime function (just with an added minus sign).
                x+                 This gets added to x, which subtracts the previous
                                   prime from it.
2>(                           )    Finally, we check whether the result is less than 2.
```
[Answer]
# Python, with sympy, 60 bytes
```
import sympy
f=lambda n:n>2and f(n-sympy.prevprime(n))or n<2
```
---
My previous method was 83 bytes without sympy using recursion, but I took truthy/falsey to mean distinguishable and consistent, but I have been informed that's an incorrect interpretation. I can't seem to salvage it due to the tail, but I'll leave it here in case someone knows how to do so:
```
f=lambda n,p=0:n>2and(any(p%x==0for x in range(2,p))and f(n,p-1)or f(n-p,n+~p))or n
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 27 bytes
```
{⍵<3:⍵=1⋄∇⍵-⊃⌽(⊢~∘.×⍨)2↓⍳⍵}
 ⍵<3 ⍝ Termination condition
   :⍵=1 ⍝ return value
     ⋄ ⍝ Separator
       ∇ ⍝ Recursive call
         ⍵-⊃⌽ ⍝ Subtract largest prime
           (⊢~∘.×⍨) ⍝ Calculate primes less than argument
             2↓⍳⍵ ⍝ Range 2–(N-1)
```
[Try it online!](https://tio.run/##HY89DkFREIV7q1BSEHdm/DxhASprkMjTSGhFaAiCJxIRapVelCo7mY0891PMyZ0535zJHUzHleFsMJ6Mcj9de33fnGt5GnXu2buj7ajd4Ie177bxWfH9yo@fku8fS9/dq9@bZ8@y@Obi2Sv6izxPi1pIixarEasVK9SQgAiCFzBDEwEREMEVtgVEQAREkigKoiCKq3UEVwkwXOOGgRiIEWAgBlIHYYsJiYFTgUmgFbaFVsCVVkGUHAWx/9dALPkB "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 11 bytes
```
1|-↙Xṗ∧X≜!↰
```
[Try it online!](https://tio.run/##FY47CgJBEESvMm48itPd/hK9hiAGKn4CQfCDiJooLG5mJoK5qYmB3mbnIuszKKiu19X0cDkYzXbzxVSK/TZx5bZLtp19TF/xdI6XZ7JebsaV5PC3k8F8hT/m3@yYv69FOJRjeu/mnxu0G7NHiVpR9NQ7867uXdO7UEUBCSINxKGBYAITcqEgMIEJTFreKUxhSq41RK50jNy4ZzCDGR2DGawGY5WJA4GjgSnghYLghSXFK0wpKsz@38Ks1f8B "Brachylog – Try It Online")
```
1              The input is 1,
 |             or:
       X≜      X is the integer with the least absolute value such that
  -↙X          it is positive, and if it is subtracted from the input
     ṗ∧        the result is prime.
         !     Consider no other value of X.
          ↰    Call this predicate again with X as the input.
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 7 bytes
```
‡∆ṗεẊ1=
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%E2%80%A1%E2%88%86%E1%B9%97%CE%B5%E1%BA%8A1%3D&inputs=48&header=&footer=)
Very nice and neat answer (flagless too!)
## Explained
```
‡∆ṗεẊ1=
‡∆ṗε    # lambda x: abs(x - prev_prime(x))
    Ẋ   # repeat that on the input until it doesn't change
     1= # does that equal 1?
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), 13 bytes
```
`tqZq0)-t2>}o
```
[Try it online!](http://matl.tryitonline.net/#code=YHRxWnEwKS10Mj59bw&input=NTA) Or [verify all test cases at once](http://matl.tryitonline.net/#code=YGkiQApgdHFacTApLXQyPn1vCl1ddiFEVA&input=WzMgNCA2IDggMTAgMTEgMTIgMTQgMTYgMTcgMTggMjAgMjIgMjMgMjQgMjYgMjcgMjkgMzAgMzIgMzQgMzUgMzcgMzggNDAgNDEgNDIgNDQgNDYgNDcgNDggNTBdCls1IDcgOSAxMyAxNSAxOSAyMSAyNSAyOCAzMSAzMyAzNiAzOSA0MyA0NSA0OV0).
### Explanation
```
`        % Do...while
  t      %   Duplicate. Takes input implicitly in the first iteration
  qZq    %   All primes less than that
  0)     %   Get last one
  -      %   Subtract (this result will be used in the next iteration, if any)
  t      %   Duplicate
  2>     %   Does it exceed 2? If so: next iteration. Else: execute the "finally" 
         %   block and exit do...while loop
}        % Finally
  o      %   Parity. Transforms 2 into 0 and 1 into 1
         % End do...while implicitly
         % Display implicitly
```
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), ~~21~~ 16 bytes
*Thanks to Dennis for saving 4 bytes.*
```
ri{_1|{mp},W=-}h
```
[Try it online!](http://cjam.tryitonline.net/#code=cml7XzF8e21wfSxXPS19aA&input=OQ)
### Explanation
```
ri       e# Read input and convert to integer N.
{        e# Run this block as long as N is positive (or until the program aborts
         e# with an error)...
  _1|    e#   Duplicate and OR 1. This rounds up to an odd number. For N > 2, this
         e#   will never affect the greatest prime less than N.
  {mp},  e#   Get all primes from 0 to (N|1)-1.
         e#   For N > 2, this will contain all primes less than N.
         e#   For N = 2, this will contain only 2.
         e#   For N = 1, this will be empty.
  W=     e#   Select the last element (largest prime up to (N|1)-1).
         e#   For N = 1, this will result in an error and terminate the program, which
         e#   still prints the stack contents though (which are 1, the desired output).
  -      e#   Subtract from N. Note that this gives us 0 for N = 2, which terminates the 
         e#   loop.
}h
```
[Answer]
# Perl, 42 bytes
Includes +1 for `-p`
Run with input on STDIN
`reach1.pl`:
```
#!/usr/bin/perl -p
$_=1x$_;$_=$`while/\B(?!(11+)\1+$|$)|11$/
```
Uses the classic primality regex
[Answer]
## .NET Regex, 38 bytes
Just to show that it can be checked in a single regex.
```
^(?>(?<=(.*))..+(?<!^\1\2+(.+.)|$))+.$
```
Input is assumed to be in unary.
### Explanation
It simply implements the requirement to the word, repeatedly removing the biggest prime and check whether there remainder is 1.
* `(?>(?<=(.*))..+(?<!^\1\2+(.+.)|$))+`: Non-backtracking group makes sure the biggest prime we found is not overriden, and `+` simply repeat the process of matching the biggest prime.
	+ `(?<=(.*))..+(?<!^\1\2+(.+.)|$)`: Match the biggest prime less than the remaining number
	
	
		- `(?<=(.*))`: Record how much we have subtracted to establish an "anchor" point for assertion.
		- `..+`: Look for the biggest number...
		- `(?<!^\1\2+(.+.)|$)`: ... which is prime and less than the remaining number.
			* `(?<!^\1\2+(.+.))`: The usual prime test routine, with `^\1` tacked in front to make sure we are checking the amount matched by `..+`
			* `(?!<$)`: Assert less than the remaining number
[Answer]
# Python 2.7: ~~88~~ 87 Bytes
```
r=lambda n:n>2and r(n-[a for a in range(2,n)if all(a%b for b in range(2,a))][-1])or n<2
```
Thx @TuukkaX for -1 more byte!
[Answer]
# [Factor](https://factorcode.org/) + `math.primes`, 51 bytes
```
[ [ dup 1 - primes-upto last - dup 2 > ] loop 1 = ]
```
[Try it online!](https://tio.run/##JY@5TsNAGIT7PMX3AkH@D18gaBENDaKKUhizKBG219jrAiGe3TikGWkuaeajaVOc1teXp@fHWz7DNISOvkmnf7gZp3MfZsYppPS9kSExh68lDO2mniN3u90PhlNQIRkiiCKOFEiJVGiGKmqoowVaojWWYYo5lmMlVuEZLrjijhd4iVfkGTvIKakRQ3KkRgXN0QoTzLACq/FtQ47X/K4HDrwvI8Ke6/z9MqZI18xpky6W8sCRLsZL6p7j1hmv5966zWhjP8Y5EJr2tP4B "Factor – Try It Online")
[Answer]
# Vitsy, ~~28~~ 26 bytes
This can definitely be shortened.
```
<]xN0)l1)-1[)/3D-];(pD-1[D
```
‮
```
<                    Traverse the code in this direction, rotating on the line.
                     For the sake of reading the code easier, I'm reversing the
                     code on this line. This will be the order executed.
 D[1-Dp(;]-D3/)[1-)1l)0Nx]
 D                         Duplicate the top member of the stack.
  [      ]                 Do the stuff in brackets until break is called.
   1-                      Subtract 1 from the top item of the stack.
     D                     Duplicate the top member of the stack.
      p(                   If the top member is a prime...
        ;                  break;
          -                Pop a, b, push a - b.
           D3/)[         ] If this value is less than 3, do the bracketed code.
                1-         Subtract the top item of the stack by 1.
                  )        If the top item is zero...
                   1       Push 1.
                    l)     If the length of the stack is zero...
                      0    Push 0.
                       N   Output the top member of the stack.
                        x  System.exit(0);
```
[Try it online!](http://vitsy.tryitonline.net/#code=PF14TjApbDEpLTFbKS8zRC1dOyhwRC0xW0Q&input=&args=NTA)
[Answer]
# [Perl 6](http://perl6.org), ~~54 53 52~~ 51 bytes
```
{($_,{$_-($_-1...2).first: *.is-prime}...3>*)[*-1]==1}
{($_,{$_-($_-1...2).first: *.is-prime}...3>*).any==1}
{any($_,{$_-($_-1...2).first: *.is-prime}...3>*)==1}
```
```
{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}
```
## Explanation:
```
# bare block lambda with implicit parameter ｢$_｣
# used to generate all of the rest of the elements of the sequence
{
  # create an any Junction of the following list
  any(
    $_, # initialize sequence with the inner block's argument
    # bare block lambda with implicit parameter ｢$_｣
    {
      # take this inner block's argument and subtract
      $_ -
      ( ^$_ )            # Range up-to and excluding ｢$_｣
      .grep(*.is-prime)\ # find the primes
      [ * - 1 ]          # return the last value
    }
    ...   # keep doing that until
    3 > * # the result is less than 3
  # test that Junction against ｢1｣
  # ( returns an ｢any｣ Junction like ｢any(False, False, True)｣ )
  ) == 1
}
```
## Example:
```
# show what is returned and if it is truthy
sub show ($_) {
  # ｢.&{…}｣ uses the block as a method and implicitly against ｢$_｣
  my $value = .&{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}
  say join "\t", $_, ?$value, $value.gist;
}
show 3;  # 3    True    any(False, True)
show 4;  # 4    True    any(False, True)
show 5;  # 5    False   any(False, False)
show 10; # 10   True    any(False, False, True)
show 28; # 28   False   any(False, False, False)
show 49; # 49   False   any(False, False)
show 50; # 50   True    any(False, False, True)
```
[Answer]
# [Irregular](https://dinod123.neocities.org/irregular.html), 63 bytes
```
p~?1_$-1p:;
n=i(0)?1_$-1p:;
_~
N=n
1(?!(11+)\1+$)11+~1
^11$~0
N
```
I created this language two days ago, and the basic premises are that there are no built in loops, the only features are basic arithmetic and decision making, and program evaluation is based on regular expressions.
## Explanation
```
p~?1_$-1p:;
n=i(0)?1_$-1p:;
_~
N=n
```
This part converts the input into unary. It repeatedly subtracts 1 from the input until it equals 0, prepending `1_` each time. It then removes all of the `_`s. If I hadn't forgotten a `break` in my code it could be written as so:
```
p~?1_$-1p:;
_~
n=i(0)?1_$-1p:;
```
The next part repeatedly removes the largest prime from the input until it is equal to `1` or `11`, with `11` being replaced with `0`.
```
1(?!(11+)\1+$)11+~1
^11$~0
N
```
I used the regex from [Martin Ender's answer](https://codegolf.stackexchange.com/a/92929/41938).
[Answer]
## PowerShell v2+, 81 bytes
```
param($n)while($n-gt2){$n-=(($n-1)..2|?{'1'*$_-match'^(?!(..+)\1+$)..'})[0]}!--$n
```
Takes input `$n`. Enters a `while` loop so long as `$n` is still `3` or greater. Each iteration, subtracts a number from `$n`. The number is the results of the [regex primality test](https://codegolf.stackexchange.com/a/57636/42963) applied against a range `($n-1)..2` via the `Where-Object` (`?`) operator, then the first `[0]` of the results (since the range is decreasing, this results in the largest one being selected). After concluding the loop, `$n` is either going to be `1` or `2`, by definition, so we pre-decrement `$n` (turning it into either `0` or `1`), and take the Boolean-not `!` thereof. That's left on the pipeline and output is implicit.
### Examples
```
PS C:\Tools\Scripts\golfing> 3..20|%{"$_ --> "+(.\can-the-number-reach-one.ps1 $_)}
3 --> True
4 --> True
5 --> False
6 --> True
7 --> False
8 --> True
9 --> False
10 --> True
11 --> True
12 --> True
13 --> False
14 --> True
15 --> False
16 --> True
17 --> True
18 --> True
19 --> False
20 --> True
```
[Answer]
# [Floroid](https://github.com/TuukkaX/Floroid), 45 30 29 bytes
```
f=Bb:b<2Fb<3Gf(b-en(b-1)[-1])
```
[Answer]
# Clojure, 125 bytes
```
#(loop[x %](if(> x 2)(recur(- x(loop[y(dec x)](if(some zero?(vec(for[z(range 2 y)](mod y z))))(recur(dec y))y))))(quot 1 x)))
```
Yikes, that is one long piece of code. The most verbose language strikes again!
Ungolfed:
```
(defn subprime [n]
  (loop [x n]
    (if (> x 2)
      (recur
        (- x
          (loop [y (dec x)]
            (if (some zero? (vec (for [z (range 2 y)] (mod y z))))
              (recur (dec y)) y))))
      (quot 1 x))))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ΔD<ÅPà-
```
Outputs `2` as falsey (only `1` is truthy in 05AB1E).
[Try it online](https://tio.run/##yy9OTMpM/f//3BQXm8OtAYcX6P7/b2gEAA) or [verify all test cases](https://tio.run/##yy9OTMpM/W@sYGpwdEdZpb2SwqO2SQpK9pX/z01xsTncGnB4ge7/Wp3/AA).
**Explanation:**
Unfortunately the *previous prime* builtin `ÅM` goes into an infinite loop for \$\leq2\$, otherwise it could have been used to save a few bytes.
```
Δ        # Loop until the result no longer changes:
 D       #  Duplicate the current value
         #  (which is the implicit input-integer in the first iteration)
  <ÅP    #  Pop it, and push a list of all primes < this value:
  <      #   Decrease the value by 1
   ÅP    #   Pop and push a list of all primes <= this value-1
     à   #  Pop and push the maximum prime of this list
         #  (or an empty string if the list is empty)
      -  #  Subtract it from the value (where subtracting the empty string is a no-op)
         # (after which the found result is output implicitly)
```
[Answer]
# Haskell, 79 bytes
Not really short but pointfree :)
```
(<2).until(<3)(until(flip(`until`(+1))2.(.)(<1).mod>>=(==))pred.pred>>=flip(-))
```
[Answer]
# Matlab, 51 bytes
```
v=@(x)x-max(primes(x-1));while(x>=3)x=v(x);end;x==1
```
This is VERY similar to the JS6 solution by [ETHProductions](https://codegolf.stackexchange.com/users/42545/ethproductions), but needs the variable to be in the workspace.
]