#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int DigitSum(unsigned int num) { int sum = 0; int n = 0; if (num != 0) { n = num % 10; num = num / 10; sum = n + DigitSum(num); } return sum; } int main() { unsigned int num = 1729; printf("%d\n", DigitSum(num)); system("pause"); return 0; }