Code review of code to strip 0 from decimal series
The following code would strip 0 (all numbers ending with 0, it can
contain 0, eg: 105 can be is valid but 150 should be eliminated) and
return a number in decimal series if all numbers ending with 0 were
stripped. Example : 0 -> 1, 10 -> 11, 19 -> 22. I would just appreciate
any code reviews. Thanks
public static int getStrippedNumber(int num) {
int setId = (num / 10) + 1;
int newNum = num + setId;
int newNumSetId = (newNum / 10) + 1;
int numberToReturn = num + newNumSetId;
return numberToReturn % 10 ==0 ? numberToReturn + 1 : numberToReturn;
}
No comments:
Post a Comment