[seqfan] Re: Sum avoidance on a decimal string

C.R. Drost c.r.drost at gmail.com
Thu Sep 26 18:22:11 CEST 2019


I think I have deciphered it. Haskell code:

-- We start from the base sequence of decimal digits,
baseSeq :: [Int]
baseSeq = map (read . (\x -> [x])) . concatMap show [1 ..]
-- baseSeq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, ...]

-- We define the consecutive subsequences of a finite sequence
consecutiveSubsequences :: [x] -> [[x]]
consecutiveSubsequences list = [take i (drop j list) | let len = length
list, i <- [1 .. len], j <- [0 .. len - i]]
-- e.g. consecutiveSubsequences [1,2,3] = [[1], [2], [3], [1,2], [2,3],
[1,2,3]]

-- and the sums of those subsequences, call them consecutive-sums.
consecutiveSums :: [Int] -> [Int]
consecutiveSums = map sum . consecutiveSubsequences
-- e.g. consecutiveSums [1,2,3] = [1, 2, 3, 3, 5, 6]

-- The desired sequence for each n takes the first n numbers from the base
sequence,
-- call that the n-prefix. It then calculates an ascending sequence of
numbers.
-- a(n) is the smallest number larger than a(n-1) which is not an element
of the
-- consecutive-sums of the n-prefix:
desiredSeq :: [Int]
desiredSeq = go 1 1 where
  go last i = next : go next (i + 1) where
    sums = consecutiveSums (take i baseSeq)
    next = head (dropWhile (\x -> x `elem` sums) [last + 1 ..])
-- so that desiredSeq = [2, 4, 7, 8, 11, 13, 16, 17, 19, 23, 29, 34, 49,
50, 52, 53, 56, 57, 58, 62, 64, 68, 69, 75, 76, 77, 83, ...]



On Thu, Sep 26, 2019 at 6:52 AM Neil Sloane <njasloane at gmail.com> wrote:

> That's very confusing!
> "Form a string K by concatenating the ordered set of Natural numbers from 1
> to infinity.  Then a(n) is the least x > a(n-1) where x does not equal
> Sum{a_i..a_j} a_i, for i >= 1; with a_i some single digit in K, and with n
> >= j-i."
> Could you explain in detail how a(1), a(2), a(3) say are calculated? The
> recursive summation Sum{a_i..a_j} a_i
> is new to me!
>
> Best regards
> Neil
>
> Neil J. A. Sloane, President, OEIS Foundation.
> 11 South Adelaide Avenue, Highland Park, NJ 08904, USA.
> Also Visiting Scientist, Math. Dept., Rutgers University, Piscataway, NJ.
> Phone: 732 828 6098; home page: http://NeilSloane.com
> Email: njasloane at gmail.com
>
>
>
> On Thu, Sep 26, 2019 at 5:00 AM Christopher Hohl via SeqFan <
> seqfan at list.seqfan.eu> wrote:
>
> > Hi seqfans!
> > Form a string K by concatenating the ordered set of Natural numbers from
> 1
> > to infinity.  Then a(n) is the least x > a(n-1) where x does not equal
> > Sum{a_i..a_j} a_i, for i >= 1; with a_i some single digit in K, and with
> n
> > >= j-i.
> > The first twelve entries (done on paper) are the following;
> > 2,4,7,8,11,13,16,17,19,23,29,50,...
> > Fairly 'odious' to start, but quite quickly things run amok.
> > Looking for help computing much higher terms, if anyone has the interest-
> > or the time.
> > Although it is a fair impossibility, here's hoping everyone is well!
> >                 ~ Christopher Hohl
> > Sent from Yahoo Mail on Android
> >
> > --
> > Seqfan Mailing list - http://list.seqfan.eu/
> >
>
> --
> Seqfan Mailing list - http://list.seqfan.eu/
>



More information about the SeqFan mailing list