+ 1

Why my code doesn't work?

Why my code doesn't work? https://code.sololearn.com/W4p8LHP9fvM8/?ref=app

5th Aug 2017, 4:56 PM
Ivan Gobrusev
Ivan Gobrusev - avatar
2 Answers
+ 4
@ValentinHacker is offtopic ;P Your mistake is when you divide by two the 'num' variable: this give you floating result, but you're expecting integer value... There is mainly 2 ways to fix it: num = Math.floor(num / 2); or : num = (num- rem)/ 2;
6th Aug 2017, 5:00 PM
visph
visph - avatar
+ 15
(Put a "return false" at the end of your function...)
5th Aug 2017, 5:03 PM
Valen.H. ~
Valen.H. ~ - avatar