xiqe / code-train

前端算法
0 stars 0 forks source link

Count Odd Numbers below n #182

Open xiqe opened 5 years ago

xiqe commented 5 years ago

Count Odd Numbers below n

Given a number n, return the number of positive odd numbers below n, EASY!

oddCount(7) //=> 3, i.e [1, 3, 5]
oddCount(15) //=> 7, i.e [1, 3, 5, 7, 9, 11, 13]

reply

const oddCount = n => Math.floor(n/2);