a-conjecture-of-mine
An exercise on polyglossy: the same problem solved on multiple languages
script.py (694B)
1 # This script is a simple test for the following conjecture: 2 3 # Let S: N -> N be the sum of the digits of a positive integer. 4 # For all A and B in N, S(A + B) = S(A) + S(B) - 9k, where k is an interger. 5 6 def sum_digits(n: int) -> int: 7 parc = abs(n) 8 sum_d = 0 9 10 while parc > 0: 11 sum_d += parc % 10 12 parc //= 10 13 14 return sum_d 15 16 def get_sums(m: int) -> list: 17 return [sum_digits(i) for i in range(2 * m)] 18 19 def counterexempl(m: int) -> bool: 20 sums = get_sums(m) 21 22 for a in range(m + 1): 23 for b in range(a, m + 1): 24 diff = sums[a + b] - sums[a] - sums[b] 25 if diff % 9 != 0: return True 26 27 return False 28