[Question]
  [
**Question :**
You will be given the starting and ending integers of a sequence and should return the number of integers within it which do not contain the digit `5`. The start and end numbers should be included!
> 
> **Examples:**
> 
> 
> 1,9 ‚Üí 1,2,3,4,6,7,8,9 ‚Üí Result 8
> 
> 
> 4,17 ‚Üí 4,6,7,8,9,10,11,12,13,14,16,17 ‚Üí Result 12
> 
> 
> 50,60 ‚Üí 60 ‚Üí Result 1
> 
> 
> -59,-50 ‚Üí ‚Üí Result 0
> 
> 
> 
The result may contain five.
The start number will always be smaller than the end number. Both numbers can be also negative!
I'm very curious for your solutions and the way you solve it. Maybe someone of you will find an easy pure mathematics solution.
**Edit**
This is a code-golf challenge, so the shortest code wins.
  
[Answer]
## JavaScript (ES6), ~~36~~ 33 bytes
Takes input with currying syntax `(a)(b)`.
```
a=>F=b=>b<a?0:!/5/.test(b)+F(b-1)
```
### Formatted and commented
```
a =>                 // outer function: takes 'a' as argument, returns F
  F = b =>           // inner function F: takes 'b' as argument, returns the final result
    b < a ?          // if b is less than a
      0              //   return 0
    :                // else
      !/5/.test(b) + //   add 1 if the decimal representation of b does not contain any '5'
      F(b - 1)       //   and do a recursive call to F with b - 1
```
### Test cases
```
let f =
a=>F=b=>b<a?0:!/5/.test(b)+F(b-1)
console.log(f(1)(9))
console.log(f(4)(17))
console.log(f(50)(60))
console.log(f(-50)(-59))
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~8~~ 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 byte thanks to Dennis (use fact that indexing into a number treats that number as a decimal list)
```
rAw‚Ç¨5¬¨S
```
**[TryItOnline!](https://tio.run/nexus/jelly#@1/kWP6oaY3poTXB////1zU1/K9rYgIA)**
# How?
```
rAw‚Ç¨5¬¨S - Main link: from, to    e.g. -51, -44
r       - range(from, to)        e.g. [-51,-50,-49,-48,-47,-46,-45,-44]
 A      - absolute value         e.g. [51,50,49,48,47,46,45,44]
  w‚Ç¨    - first index of... for ‚Ç¨ach (0 if not present)
    5   - five                   e.g. [1,1,0,0,0,0,2,0]
     ¬¨  - logical not            e.g. [0,0,1,1,1,1,0,1]
      S - sum                    e.g. 5
```
\* The absolute value atom, `A` is necessary since a negative number cast to a decimal list has negative entries, none of which would ever be a `5` (the given example would count all eight rather than two).
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + grep, 17 bytes
```
seq $@|grep -cv 5
```
[Try it online!](https://tio.run/nexus/bash#@1@cWqig4lCTXpRaoKCbXKZg@v//f5P/huYA "Bash ‚Äì TIO Nexus")
[Answer]
# [2sable](https://github.com/Adriandmen/2sable), ~~6~~ 5 bytes
Saved a byte thanks to *Adnan*
```
≈∏5¬¢_O
```
[Try it online!](https://tio.run/nexus/2sable#@390h@mhRfH@//9Hm@gYmscCAA "2sable ‚Äì TIO Nexus")
**Explanation**
```
 ≈∏      # inclusive range
  5¬¢    # count 5's in each element of the range
    _   # negate
     O  # sum
```
**Note:** This works due to a bug in `¬¢` making the function apply itself to each element instead of counting matching elements in the list.
[Answer]
# Python2, ~~59~~ ~~55~~ ~~52~~ ~~51~~ ~~47~~ ~~43~~ 42 bytes
```
f=lambda a,b:a<=b and-(`5`in`a`)-~f(a+1,b)
```
A recursive solution. Thanks to [@xnor](https://codegolf.stackexchange.com/users/20260/xnor) for giving me motivation to find a solution using logical operators! Also, thanks to [@JonathanAllan](https://codegolf.stackexchange.com/users/53748/jonathan-allan) and [@xnor](http://@https://codegolf.stackexchange.com/users/20260/xnor) for guiding me and chopping the byte from 43 to 42!
# Other attempts at 43 bytes
```
f=lambda a,b:a<=b and-~-(`5`in`a`)+f(a+1,b)
f=lambda a,b:a<=b and 1-(`5`in`a`)+f(a+1,b)
```
[Answer]
# [Bash](https://www.gnu.org/software/bash/) / Unix utilities, 21 bytes
```
seq $*|sed /5/d|wc -l
```
[Try it online!](https://tio.run/nexus/bash#@1@cWqigolVTnJqioG@qn1JTnqygm/P//3@T/4bmAA "Bash ‚Äì TIO Nexus")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~8~~ ~~7~~ 6 bytes
Saved a byte thanks to *Adnan*
```
≈∏5.√•_O
```
[Try it online!](https://tio.run/nexus/05ab1e#@390R1ml6eGl8f7//5twGZoDAA "05AB1E ‚Äì TIO Nexus")
**Explanation**
```
≈∏         # inclusive range
 5.√•      # map 5 in y for each y in the list
    _     # logical negation 
     O    # sum
```
[Answer]
# Pyth, ~~9~~ 8 bytes
Saved a byte thanks to FryAmTheEggman!
```
lf-\5T}E
```
Explanation:
```
        Q # Input
      }E  # Form an inclusive range starting from another input
          #   order is reversed, but doesn't matter
 f-\5T    # Filter by absence of '5'
l         # Count the number of elements left
```
[Try it online!](http://pyth.herokuapp.com/?code=lf-%5C5%60T%7DE&input=4%0A17&debug=0)
[Answer]
# [Perl 6](http://perl6.org/), 23 bytes
```
{+grep {!/5/},$^a..$^b}
```
[Try it online!](https://tio.run/nexus/perl6#Ky1OVSgz00u25uLKrVRQS1Ow/V@tnV6UWqBQrahvql@roxKXqKenEpdU@784sVIhTcFQR8HSmgvCNtFRMDS3/g8A "Perl 6 ‚Äì TIO Nexus")
### How it works
```
{                     }  # A lambda.
              $^a..$^b   # Range between the two lambda arguments.
  grep {!/5/},           # Get those whose string representation doesn't match the regex /5/.
 +                       # Return the size of this list.
```
[Answer]
# [Haskell](https://www.haskell.org/), 39 bytes
```
s!e=sum[1|x<-[s..e],notElem '5'$show x]
```
[Try it online!](https://tio.run/nexus/haskell#@1@smGpbXJobbVhTYaMbXaynlxqrk5df4pqTmqugbqquUpyRX65QEfs/NzEzT8FWoaAoM69EQUXBRNHQ/D8A "Haskell ‚Äì TIO Nexus") Usage: 
```
Prelude> 4 ! 17
12
```
Explanation:
```
             [s..e]                     -- yields the range from s to e inclusive
          x<-[s..e]                     -- for each x in this range
          x<-[s..e],notElem '5'$show x  -- if the char '5' is not in the string representation of x
       [1|x<-[s..e],notElem '5'$show x] -- then add a 1 to the resulting list      
s!e=sum[1|x<-[s..e],notElem '5'$show x] -- take the sum of the list
```
[Answer]
# R, 33 bytes
```
f=function(x,y)sum(!grepl(5,x:y))
```
Usage:
```
> f=function(x,y)sum(!grepl(5,x:y))
> f(40,60)
[1] 10
> f(1,9)
[1] 8
> f(4,17)
[1] 12
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 36 bytes
```
@(m,n)sum(all(dec2base(m:n,10)'-52))
```
[Try it online!](https://tio.run/nexus/octave#@@@gkauTp1lcmquRmJOjkZKabJSUWJyqkWuVp2NooKmua2qkqfk/Ma9Yw0TH0FzzPwA "Octave ‚Äì TIO Nexus")
[Answer]
## Groovy, ~~47~~ ~~45~~  ~~43~~ 40 bytes
```
{a,b->(a..b).findAll{!(it=~/5/)}.size()}
```
This is an unnamed closure. [`findAll`](http://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Collection.html#findAll(groovy.lang.Closure)) is similar to adding an `if` condition in a list comprehension in python.
[Try it online!](https://tio.run/nexus/groovy#@59mW52ok6Rrp5Gop5ekqZeWmZfimJNTraiRWWJbp2@qr1mrV5xZlaqhWcsVHW2gYxqrE22iY2gOpAx1DA2gFIg2BUqaxsbqpSYmZ1QXFGXmleTkKaQBjYkGygJJw1jN2v//AQ)
[Answer]
# PHP 7.1, ~~57~~ 55 bytes
```
for([,$a,$b]=$argv;$a<=$b;)$n+=!strstr($a++,53);echo$n;
```
Run with `php -r '<code>' <a> <b>`
[Answer]
# Mathematica, ~~46~~ ~~44~~ 42 bytes
*Thanks to alephalpha and DavidC for saving 2 bytes each!*
```
Tr@Boole[FreeQ@5/@IntegerDigits@Range@##]&
```
Unnamed function taking two integer arguments and returning an integer. `IntegerDigits@Range@##` converts all the numbers between the inputs into lists of digits; `FreeQ@5` tests those lists to decide which ones do not contain any `5`. Then `Boole` converts booleans to zeros and ones, and `Tr` sums the results.
Other solutions (44 and 47 bytes):
```
Count[Range@##,x_/;IntegerDigits@x~FreeQ~5]&
```
`IntegerDigits@x~FreeQ~5` determines whether the list of digits of a number is free of 5s, and `Count[Range@##,x_/;...]&` counts how many numbers between the inputs pass that test.
```
Tr[Sign[1##&@@IntegerDigits@#-5]^2&/@Range@##]&
```
`1##&@@IntegerDigits@#-5` takes the list of digits of a number, subtracts 5 from all of them, and multplies the answers together; `Sign[...]^2` then converts all nonzero numbers to 1.
[Answer]
## Ruby, ~~36~~ 35 bytes
```
->a,b{(a..b).count{|x|!x.to_s[?5]}}
```
Thx IMP1 for -1 byte
[Answer]
# Java 7, ~~80~~ 78 bytes
```
int c(int a,int b){int r=0;for(;a<=b;)r+=(""+a++).contains("5")?0:1;return r;}
```
**Ungolfed:**
```
int c(int a, int b){
  int r = 0;
  for (; a <= b; ) {
    r += ("" + a++).contains("5")
          ? 0
          : 1;
  }
  return r;
}
```
**Test code:**
[Try it here.](https://ideone.com/hR2BBr)
```
class M{
  static int c(int a,int b){int r=0;for(;a<=b;)r+=(""+a++).contains("5")?0:1;return r;}
  public static void main(String[] a){
    System.out.println(c(1, 9));
    System.out.println(c(4, 17));
  }
}
```
**Output:**
```
8
12
```
[Answer]
# PowerShell, ~~42~~ 41 bytes
```
param($a,$b)$a..$b|%{$z+=!($_-match5)};$z
```
Called from the command line as .\no5s.ps1 1 20
[Answer]
# Regex `üêá` (Perl / PCRE), ~~160~~ 147 bytes
`^(?(?=-x*,(?!-))-?+x*(,x*(?!$))?|-?(?=(x*),-?(x*))(?=(x*),?(?=\2)(?=\3)(x*,-?|[^,]*)(x*))\4,?+x*)(?!((?=(x+)(\8{9}x*))\9)*(x{10})*x{5}\b)(?(4)\4\6)`
[Try it online!](https://tio.run/##RVDNUoMwEL7zFGkmhyxs2qBQpZSmztSrJ29imZZpZ3Boi1BncCgefQAf0RepCx31kGy@v80mxabM/fPunYkyZE1@SFc5E6OQYDRd3D3ezVpreyilqCIdTmchNCzbEoKmKLP9kfF4z8OWVJcieVS9rasjuRNULrqwee10889q4mEikpC6MClyajenVJFnR8mRIzGhxZhI6Tb2csj2PbtbFQ2lp9pwxSecw5DXvGardUUstPMcoo@RNBNRgjSmcRyRom6BXnEZ8q8ROYecfX9@MT4UKU18ormttk2S@4dFkpyX0kgTqdpGaQYKQBmntiXSMgMBYE6q02VtA9KJCvzCjo@vOhhfAzGkn56W@GxDb4s97FqRPpB9xAEZ3zZB24sB2LJuXBrZrhu/jdfkkx6F4jGczy4GlofujeVrHGtL@QEq/1I76GqNLlUvCALsNqv7@h8 "Perl 5 ‚Äì Try It Online") - Perl  
[Try it online!](https://tio.run/##hVbrbuJGFP7PU0zYKsyYIcW5NeA4KE2QgpSQFUvU7YasZcwAVszY8mVDLvztA/QR@yBNz1wMJrAqAnvmXL5znTN4UVSbeN77pxEb@5yhzxe99r5zcXvZdu66nb7zR@eyf4VOSp987gXZiKHTyIvZ/t70rORN3Rg50f0DslGv/PvT0@PwIPvz@flrf3r8NMXv33ELt@za3KC4tVMjpNaqzg1M4dfa@YWQ1ltN8PHcIBRW8CL5VtAH@2I7OCBAAf7b/Xf6YBApNjikAgr4O1iqVAkenLw2FpLZIAaev5r1BTHmr0eLwRDk8CEoDY7JO/noZpkiI7KdqGpahRiTNPb5RAS5ovkhUJk7O9uQOyv5PEURLFOHxXEYYy/kSYpkgowZSxJ3wgh6TdJRs@mBBDo9RZoslpLO@CiwUMzSLObItBYbmGLvhSNG0TAMAxTaYzdIBKw0o@Hu94@OH6wSgo8/RljWypkwjeFoKaxwsCr23cXVee/EIJpJUeK/sHCMl47/mlMK8oQQaUV8cIhaKggvzFLURMtAiQivLNWQ9KCJyh@Cl8rlMmiVB7xMlvkYB1kyVZEsk1JalDKe@BPORigI@UQ9XJ48sdiSCZs9O54bBOCGjl3vnGEQeo/I8Cj6EfojZIzc1IXciSSJJbJthAXHILsrDKKxq9VlZeq6MjPX5xgApIPRPTRCwDiOSM18sOuWCkF1B4o8u4xbzbIFq6odqVcZuvJCdDABegaIB/tOCkUFXQE/gYWELgL5PMpSoS4DgxIiI2b5fuam3tSRsRirtUKLWZIFKVUlsPQZ/9L51paU8ThhwIR4IYRJOl0TMMIfzEtBS1cCznpufxb5AcO6Kb587vdI5O15DjiLCdUY39q9W6ff7t10uuf99mVObn/tt7uX7Uv0pgk3d9f9znWn26ZoV3qp39q3Oln19E4MLamrUTwf8qnlCsmwN/LjwN5NmTOOw5kTuWnKYo5j6Pvu3fW1BijqwGFO2TyFtOYrextfw@INFIhg2ZQ5BC10Kt3WeR8BlKnAn/lFkJpJrILQiEXp/wrFzMvixA/5VkFpdhzGSM6bl2UvwwwJ4H7A6mj7nKpuJFZ@BvLyvBAEdDGTcGXAK2D6xTYtyZIae2KWYGLbdYKEZZ9nzFohgFHoQmFWTc9kxVt6FYUJCKxZznU5e3JAnyIORXLT0NdGdVuiqlCG7uSiMdxhgrnYCGGgVBHmp3mrFWMSOh@MLc@mHHliytGytSkBwFgEYhBoDqishxMot/YSmOJZRSb8OBfemWQLyD1IVavimq3Qyjp/gRhcAtt8W1meKcMFq9ttLTbiFtlQ5qXx2gfjMzaDhsIJYKk4pAJFlXlFZBhKL3WFQWVaoOQNleeNr2NCqkFIFQ3@kIwwhEwlVTqcl0PM68JobDa5rNEQsvxoKXFbXBibsa0XDf3z198IJrCa89K9paSamuuHXc6J4siDcsp@q8vvasjAWp@rQpaF8wr1tI52d7WFHVsPxV7vtud0b2/O@xdXZD0rhTmXD/M0zlgBW/RB6afdqePbcrkufjbvYD4yhldRbM5RJbDck@LVpJgwqpc3p/Ib7vB3kzZKh9T8rXRUp8f1Uu2oQWtH6i22Zr1OTXgfNhoNKh5Aoua/3jhwJ8l7LZBGaif/AQ "C++ (gcc) ‚Äì Try It Online") - PCRE (faster)
Takes its input in unary, as two strings of `x` characters whose lengths represent the numbers, with optional `-` signs on their left side, joined by a `,` delimiter. Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method.)
Most of the logic of this regex is taken up with handling the logic of integer ranges. It's rather unnatural... literally. Natural numbers (including zero) are much easier for a regex to operate on.
```
^
(?(?=-x*,(?!-))
    # Do the following if A is negative and B is nonnegative
    -?+                     # skip sign of A, if any
    x*                      # handle the range from larger to zero, inclusive
    (,x*(?!$))?             # handle the range from B inclusive to zero exclusive
|
    # Do the following if A is nonnegative or B is negative
    -?                      # skip sign of A, if any
    (?=
          (x*),             # \2 = abs(A); 
        -?(x*)              # \3 = abs(B)
    )
    (?=
        (x*),?(?=\2)(?=\3)  # \4 = what to skip so tail = the larger of A or B;
                            # tail = the larger of A or B
        (x*,-?|[^,]*)(x*)   # \6 = {the smaller of A or B} - \4
    )
    \4,?+                   # tail = the larger of A or B
    x*                      # handle the range from larger to {smaller or zero}
)
(?!                         # Negative lookahead - assert this can't match
    (
        (?=(x+)(\8{9}x*))   # \8 = floor(tail / 10); \9 = tail - \8
        \9                  # tail = tail - \9 == \8
    )*                      # Iterate the above any number of times, minimum zero
    (x{10})*x{5}\b          # Assert tail % 10 == 5
)
(?(4)\4\6)                  # If \4 is set, clamp the range at the smaller end
```
It uses conditionals, which are not supported by ECMAScript, but it'd be easy enough to port (though the regex would be even longer). The `üêá` output method is required for this algorithm to be possible in ECMAScript (there isn't yet a regex engine that can emulate ECMAScript and count possible matches, but I'm planning on adding this to [RegexMathEngine](https://github.com/Davidebyzero/RegexMathEngine/) soon).
# Regex (.NET), 163 bytes
`^(?=(-x*,(?!-))?)(?>-?)(?(1)|(?=(x*),-?(x*))(?=(x*),?(?=\2)(?=\3)(x*,-?|[^,]*)(x*))\4(?>,?))(?(,)(?(1),)|(?(((?=(x+)(\8{9}x*))\9)*(x{10})*x{5}\b)|())x?)*(?(4)\4\6)`
[Try it online!](https://tio.run/##RZBBTsMwEEX3PYWJjDKT2lUMbSGtgkGsOUFSUFpMY5QmUeKqFmm2HIAjcpHiFCEW9sz/8/U0mro6qKbNVVGcaBMnjdoqu1osSnWAe//0DDIGbgMG8oIjSgR5x4cfBB6HmQ2QcTkU/JPSNenVINNrdI6bH5NntgrwHEunjsHkkAf2S2IDC@AMGCOkt13Un6MRBmA7EfYY2G7Wp2sXRLTS2RKmDpXO8eTfM@@x2tW6UK8eLulHHC7fqkZlmxxoQXRJqC7rvcGOZjEteFsX2njMWxJqY6AZOZJL0vncDyDRpVnRF14YEuLYt36QPGUmd/d4WLd/U@yRv1e6PCP0G9BdTJuJy21y1QK1iN3gfmB3aLRRPK9a07utxJL8G4SXlbtxoUtFPLfl9@cXoQ412TbVvm4TIVaTTVabfaPayabalwa9vj8JFo2mTNyMZiGbhyM@ixif/dZBijBkwtUoiph7zmDiBw "PowerShell ‚Äì Try It Online")
Returns its output as the capture count of group `\11`.
```
^
(?=
    (-x*,(?!-))?            # \1 = set iff A is negative and B is nonnegative
)
(?>-?)                      # skip sign of A, if any
(?(1)
|
    # Do the following if A is nonnegative or B is negative
    (?=
          (x*),             # \2 = abs(A); 
        -?(x*)              # \3 = abs(B)
    )
    (?=
        (x*),?(?=\2)(?=\3)  # \4 = what to skip so tail = the larger of A or B;
                            # tail = the larger of A or B
        (x*,-?|[^,]*)(x*)   # \6 = {the smaller of A or B} - \4
    )
    \4                      # tail = the larger of A or B
    (?>,?)                  # skip sign of B, if any
)
                            # First handle the range from larger inclusive to
                            # {smaller inclusive or 0 exclusive}
(?(,)
    (?(1),)                 # If crossing from negative to nonnegative, handle
                            # the inclusive range from B to 0
|
    (?(
        (
            (?=(x+)(\8{9}x*))   # \8 = floor(tail / 10); \9 = tail - \8
            \9                  # tail = tail - \9 == \8
        )*                      # Iterate the above any number of times
        (x{10})*x{5}\b          # Assert tail % 10 == 5
      )
    |
        ()                  # Push a capture onto the \11 stack
    )
    x?                      # Advance by 1, but if already at the end, allow the
                            # loop to iterate once more so as to include 0 in
                            # the count.
)*
(?(4)\4\6)                  # If \4 is set, clamp the range at the smaller end
```
It could also be ported to an output method of the sum of the lengths of two capture groups (two, because the output can exceed the largest of the two inputs), though this would probably make it significantly longer.
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 6 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
Id5»∑c~
```
(No ATO link since it's down at the moment)
#### Explanation
```
Id5»∑c~  # Implicit input   ->    1,                                  10
I       # Inclusive range  ->   [1,  2,  3,  4,  5,  6,  7,  8,  9,  10]
 d      # Cast to digits   ->  [[1],[2],[3],[4],[5],[6],[7],[8],[9],[1,0]]
   »∑    # To each list:    ->   [1] [2] [3] [4] [5] [6] [7] [8] [9] [1,0]
  5 c   #  Count 5s        ->    0   0   0   0   1   0   0   0   0   0
     ~  # Logical NOT      ->   [1,  1,  1,  1,  0,  1,  1   1,  1,  1]
        # Implicit sum     ->                      9
        # Implicit output
```
[Answer]
# Python 2, 61 56 bytes
```
lambda a,b:len([n for n in range(a,b+1) if not"5"in`n`])
```
-5 bytes thanks to tukkaaX
[Answer]
## Swift 52 bytes
```
($0...$1).filter { !String($0).contains("5") }.count
```
[Answer]
## Batch, 95 bytes
```
@set/an=0,i=%1
:g
@if "%i%"=="%i:5=%" set/an+=1
@set/ai+=1
@if %i% leq %2 goto g
@echo %n%
```
Manually looping saves some bytes because I need the loop counter in a variable anyway.
[Answer]
# PHP, 56 bytes
```
for($i=$argv[1];$i<=$argv[2];)trim(5,$i++)&&$x++;echo$x;
```
Run like this:
```
php -r 'for($i=$argv[1];$i<=$argv[2];)trim(5,$i++)&&$x++;echo$x;' 1 9 2>/dev/null;echo
> 8
```
A version for PHP 7.1 would be 53 bytes (credits to Titus):
```
for([,$i,$e]=$argv;$i<=$e;)trim(5,$i++)&&$x++;echo$x;
```
# Explanation
```
for(
  $i=$argv[1];          # Set iterator to first input.
  $i<=$argv[2];         # Loop until second input is reached.
)
  trim(5,$i++) && $x++; # Trim string "5" with the characters in the
                        # current number; results in empty string when
                        # `5` is present in the number. If that is not
                        # the case, increment `$x`
echo$x;                 # Output `$x`
```
[Answer]
# CJam "easy pure mathematics solution", 60
```
{{Ab5+_,\_5#)<\9e]);_4f>.m9b}%}:F;q~_:z$\:*0>{((+F:-}{F:+)}?
```
[Try it online](http://cjam.aditsu.net/#code=%7B%7BAb5%2B_%2C%5C_5%23)%3C%5C9e%5D)%3B_4f%3E.m9b%7D%25%7D%3AF%3Bq~_%3Az%24%5C%3A*0%3E%7B((%2BF%3A-%7D%7BF%3A%2B)%7D%3F&input=%5B-22222222%201234567890%5D)
It takes the numbers in any order, in an array.
**Explanation:**
One core problem is to calculate f(n) = the number of non-5 numbers from 1 to n (inclusive) for any positive n. And the answer is: take n's decimal digits, replace all digits after the first 5 (if any) with 9, then replace all digits 5..9 with 4..8 (decrement), and convert from base 9. E.g. 1752 ‚Üí 1759 ‚Üí 1648 ‚Üí 1\*9^3+6\*9^2+4\*9+8=1259. Basically, each digit position has 9 acceptable values, and a 5xxxx is equivalent to a 49999 because there are no more valid numbers between them.
Once we solved this, we have a few cases: if the input numbers (say a and b, a<b) are (strictly) positive, then the result is f(b)-f(a-1). If they are negative, then we can take the absolute values, reorder them and use the same calculation. And if a<=0<=b then the result is f(-a)+f(b)+1.
The program first implements the function F as described above (but applied to each number in an array), then reads the input, converts the numbers to the absolute value and reorders them, and uses one of the 2 calculations above, based on whether a\*b>0 initially.
[Answer]
# [Python 2](https://docs.python.org/2/), 54 bytes
```
i,j=input();k=0
while i<=j:k+=not"5"in`i`;i+=1
print k
```
[Try it online!](https://tio.run/nexus/python2#@5@pk2WbmVdQWqKhaZ1ta8BVnpGZk6qQaWObZZWtbZuXX6JkqpSZl5CZYJ2pbWvIVVCUmVeikP3/v66hmY4ZAA "Python 2 ‚Äì TIO Nexus")
Not the shortest Python answer Uses same algorithm but a different way of implementing with a while loop and is not a lambda function.
[Answer]
# C++ | in too many bytes, 165 125 thanks to Christoph!
```
int main(){int c=0;for(int i=0;i<=8;i++){int d;int n=i>=0?i:-i;while(n!=0){if(d=n%10==5){break;}n=n/10;c++;break;}}return c;}   
```
I took the liberty of creating a function `e_` to determine if a 5(or any other number) is present in an integer instead of using `to_string()` and `.find()` so that must count for something. *note: `e_` is only declared as an extra function in the un-golfed version for readability.*
un-golfed:
```
int e_(int e,int i){
    int d;
    int n=i>=0?i:-i;
    while (n != 0){
        d=n%10;
        if (d==e){
        return 1;}
        n=n/10;}
        return 0;}
int main() {
    int l = 1;int h = 8;int e = 5;int c = 0;
    for(int i=l; i<=h; i++){
        if (e_(e,i)==0)     
        c++;}
    return c;}
```
**How `e_` function works:**
`int n=i>=0?i:-i;` Inverses our number if it is less than 0 so it's always positive. `d=n%10;` Divides it by 10 and gets remainder (`n%base;` will always return the last digit of an integer). We check that it equals 5, if it does the number can be discarded, if not `n=n/10;` removes the end digit and loops again.
[Answer]
## Hoon, ~~110~~ 94 bytes
Hoon's range function, `gulf`, doesn't work for signed integers, which increases the length by a bit :(
```
=+
si^f=:(curr lien test 53)
|=
{a/@s b/@s}
|-
?:
=(a b)
(f <b>)
(add (f <a>) $(a (sum -1 a)))
```
Use the signed integer library. Create a function `f`: `:(a b c d)` is a macro that expands into `(a b (a c d))` so this is `(curr lien (curr test 53))`, aka create a curried function that tests if any element of a list is 53 (`'5'`)
Create a function that takes `a` and `b`. Create a loop: if `a==b` return `f(tostring(b))`, else return `add(f(tostring(a)) recurse(a=a+1))`
```
> =f =+
  si^f=:(curr lien test 53)
  |=
  {a/@s b/@s}
  |-
  ?:
  =(a b)
  (f <b>)
  (add (f <a>) $(a (sum -1 a)))
> (f -1 -9)
8
> (f -4 -17)
12
> (f -50 -60)
1
> (f --59 --50)
0
```
(Hoon's signed integers use `-` as a prefix, so `--5` is negative 5 and `-5` is positive 5)
[Answer]
# SmileBASIC, 55 bytes
```
INPUT S,E
FOR I=S TO E
INC N,INSTR(STR$(I),"5")<0NEXT?N
```
Nothing special, just uses `INSTR` and `STR$` to check for `5`.
[Answer]
# Java 7, 77 bytes
This is an improvement of [Kevins Answer](https://codegolf.stackexchange.com/a/107475/58696), but since I don't have the reputation to comment yet, this new answer will have to do.
So what I did was:
* Replace the `indexOf` statements with `contains` (-1 byte)
* Move the incrementing part of the for-loop into the conditional statement (-2 bytes)
---
for-loop (**77 bytes**):
```
int c(int a,int b){int r=1;for(;a++<b;)r+=(""+a).contains("5")?0:1;return r;}
```
recursive (**79 bytes**):
```
int d(int r,int a,int b){r+=(""+a).contains("5")?0:1;return a!=b?d(r,a+1,b):r;}
```
**Output:**
```
8
12
8
12
```
Test it *[here](http://ideone.com/X7lsXF)* !
]