Hello guys, this is my first time here, and this is my recursive approach:
function strongest(from, to, times = 0) { if (from > to) return false; if (to - from < 1) return from * (2 ** times); if (to - from < 2) return (from + (from % 2)) * (2 ** times); return strongest((from + (from % 2)) / 2, (to - (to % 2)) / 2, times + 1); }
EDIT without times:
function strongest(from, to) { if (from > to) return false; if (to - from < 1) return from; if (to - from < 2) return from + (from % 2); return 2 * strongest((from + (from % 2)) / 2, (to - (to % 2)) / 2); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello guys, this is my first time here, and this is my recursive approach:
EDIT without times: