Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Variable n contains the number of digits of the input number, it is incremented in
digits[n++] = number % 10;
.The comparison in the later loop is between the current iteration aka digit with the total digits n (minus 1 because i starts at 0) and divided by two because you are "cutting" the input number in two halfs: the left and the right one, so your sums will be only between the n/2 digits from each side.
The left digits sum is performed from left to right (hence
sumLeft += digits[i]
) and the right digits sum is performed from right to left (hencesumRight += digits[n-i-1]
-- note the n-i subtraction).