3 ms·
Would someone write a mathematical proof showing this is always true?
by ryao 2y ago
Would someone write a mathematical proof showing this is always true?
- afiodorov 2y agoa = [int(x) for x in str(n)][::-1] assert n == sum(d*(10**i) for i, d in enumerate(a)) Now when you're operating mod 9, 10 == 1 % 9, thus 10**i == 1 % 9 Comes from the fact that (a*b) % 9 == (a % 9) * (b % 9) Now using (a+b) % 9 == (a % 9) + (b % 9) We get that that sum(a) and n are same mod 9.
- ryao 2y agoThank you for that.