Don't give me five!

简介: Don't give me five!
In this kata you get the start number and the end number of a region and should return the count of all numbers except numbers with a 5 in it. The start and the end number are both inclusive!

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
The result may contain fives. ;-)
The start number will always be smaller than the end number. Both numbers can be also negative!

代码:

function dontGiveMeFive(start, end) {
    var r=[],i=start;
    while(i<end+1){
        var str= i.toString();
        if(str.indexOf(5)==-1){
            r.push(i++)
        }else{
            i++
        }
    }
    return r.length
}
目录
相关文章
|
3月前
|
Java Spring
allowedOrigins cannot contain the special value "*"
allowedOrigins cannot contain the special value "*"
36 0
|
传感器 监控 安全
【Matter】Matter学习笔记1(下)
【Matter】Matter学习笔记1
12159 1
|
传感器 网络协议 安全
【Matter】Matter学习笔记1(上)
【Matter】Matter学习笔记1
695 1
why SpringComponentScanServer is needed
why SpringComponentScanServer is needed
91 0
why SpringComponentScanServer is needed
E: Unable to correct problems, you have held broken packages.
在使用服务器配置环境中遇到的问题,先将解决方案列下:
|
Shell
Solving environment: failed with initial frozen solve. Retrying with flexible solve的解决方法
Solving environment: failed with initial frozen solve. Retrying with flexible solve的解决方法
12990 0
Solving environment: failed with initial frozen solve. Retrying with flexible solve的解决方法
|
数据库
When Tech Meets Love – Smarter Ways to NOT be Single
It’s that time of year again. Single’s Day (a.k.a Double 11) is just around the corner, people buying gifts for loved ones.
1625 0
When Tech Meets Love – Smarter Ways to NOT be Single