Adding the digits of a number, over and over, until one digit remains gives its digital root (38 -> 11 -> 2). You could loop, but here loops are banned: no for, no while, and no recursion either. A number and its digit sum always differ by a multiple of 9, so the answer depends only on n % 9. The root is 0 for n = 0, otherwise 1 + (n - 1) % 9. Read n (0 to 10^18) and print: Root: <root> Sample input: 38 Sample output: Root: 2