You are viewing a single comment's thread. Return to all comments →
it is strange thar -3 % 2 ==-1 in scala
so my first code :"arr.filter(_%2==1).sum" is faild when negative number in the input .
fix it by _%2!=0
Seems like cookies are disabled on this browser, please enable them to open this website
Sum of Odd Elements
You are viewing a single comment's thread. Return to all comments →
it is strange thar -3 % 2 ==-1 in scala
so my first code :"arr.filter(_%2==1).sum" is faild when negative number in the input .
fix it by _%2!=0