// sum the digits of an integer int getSum(long long n) { int sum = 0; int m = n; while(n > 0) { m = n % 10; sum = sum + m; n = n / 10; } return sum; }