DEV Community

Discussion on: Daily Challenge #153 - Horse Race Gamble

Collapse
 
bamartindev profile image
Brett Martin • Edited

Shortest answer I could think of:

const horses = n => { 
    if(Number.isInteger(n)) return n < 3 ? n : n * (n-1) * (n-2)
};

And in Standard ML, since it has type checking I can skip the int check:

fun horses(n: int) : int = if n < 3 then n else n * (n - 1) * (n - 2)