Arbitrary-Precision Digit Root & Base-B Encoder
Difficulty: Easy · Unit 1: Core Foundations & Text · Featured in: CodeTantra Lab Pattern
Given a non-negative integer N (which may exceed 64-bit integer limits, up to 10^200) and a target base B (2 <= B <= 36), compute two values: (1) the single-digit digital root of N in base 10 obtained by repeatedly summing its digits, and (2) the exact uppercase representation of N in base B.
Input & Output Format
Input: A single line containing two space-separated integers N and B.
Output: Print two space-separated tokens: <digital_root> <base_B_representation>.
Sample 1
9875 16
2 2693
9+8+7+5 = 29 -> 2+9 = 11 -> 1+1 = 2. In base 16, 9875 is 0x2693.
Sample 2
0 2
0 0
Zero stays '0' in every base, and its digital root is 0.
Free forever — sign in with email at poorvithmp.com to unlock the dry run, verified Python 3 solution, edge-case traps, and downloads.