A343951 Numbers with decimal expansion (d_1, ..., d_k) such that all the sums d_i + ... + d_j with 1 <= i <= j <= k are distinct.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27, 28, 29, 31, 32, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 65, 67, 68, 69, 71, 72, 73, 74, 75, 76, 78, 79, 81, 82
Offset: 1
Examples
Regarding 12458: - we have the following partial sums of digits: i\j| 1 2 3 4 5 ---+--------------- 1| 1 3 7 12 20 2| . 2 6 11 19 3| . . 4 9 17 4| . . . 5 13 5| . . . . 8 - as they are all distinct, 12458 is a term.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..5562
Programs
-
PARI
is(n) = { my (d=digits(n), s=setbinop((i,j)->vecsum(d[i..j]), [1..#d])); #s==#d*(#d+1)/2 }
-
Python
def ok(n): d, sums = str(n), set() for i in range(len(d)): for j in range(i, len(d)): sij = sum(map(int, d[i:j+1])) if sij in sums: return False else: sums.add(sij) return True print(list(filter(ok, range(83)))) # Michael S. Branicky, May 05 2021
Comments