Please, don't post solutions in Discourse.
This comment is hidden because it contains spoiler information about the solution
-1 + 0 = -1 + 1 = 0 + 2 = 2
I've begun learning Python coming from doing a lot of data analytics with Excel and so I approached this with the logic I would there:
if n or m is less than 1 (in other words 0 or less) return 0, otherwise multiply n & m.
For some reason it's implying that the first case (5 and 5) are both less than 1 and returning 0 when it should be 25. I have no idea why.
Edit: I've just realised you can't specify n or m <1. It has to be n <1 or m <1
Perl translation
for -5,-5 your first condition true, hence function return 25. which is wrong answer
You are not asked about sum of 5 and -1. You are asked about sum of all numbers between 5 and -1, and it is not 4.
Yeah this makes no sense.. i feel like they're not looking for the sum at all.. since the sum between 5 and -1 is.. 4..
OP solved it, closing
Yes... -1 + 0 + 1 + 2 + 3 + 4 + 5 = 14
Incorrect answer for a=5, b=-1: expected 4 to equal 14
Loading collection data...
Please, don't post solutions in Discourse.
This comment is hidden because it contains spoiler information about the solution
-1 + 0 = -1 + 1 = 0 + 2 = 2
I've begun learning Python coming from doing a lot of data analytics with Excel and so I approached this with the logic I would there:
if n or m is less than 1 (in other words 0 or less) return 0, otherwise multiply n & m.
For some reason it's implying that the first case (5 and 5) are both less than 1 and returning 0 when it should be 25. I have no idea why.
Edit: I've just realised you can't specify n or m <1. It has to be n <1 or m <1
Perl translation
Perl translation
for -5,-5 your first condition true, hence function return 25. which is wrong answer
This comment is hidden because it contains spoiler information about the solution
You are not asked about sum of 5 and -1. You are asked about sum of all numbers between 5 and -1, and it is not 4.
Yeah this makes no sense.. i feel like they're not looking for the sum at all.. since the sum between 5 and -1 is.. 4..
OP solved it, closing
Yes... -1 + 0 + 1 + 2 + 3 + 4 + 5 = 14
Incorrect answer for a=5, b=-1: expected 4 to equal 14
Loading more items...