[go: up one dir, main page]

login
Revision History for A045887 (Bold, blue-underlined text is an addition; faded, red-underlined text is a deletion.)

Showing entries 1-10 | older changes
Number of distinct even numbers visible as proper subsequences of n.
(history; published version)
#26 by OEIS Server at Wed Mar 24 22:15:20 EDT 2021
LINKS

Sean A. Irvine, <a href="/A045887/b045887_1.txt">Table of n, a(n) for n = 0..10000</a>

#25 by N. J. A. Sloane at Wed Mar 24 22:15:20 EDT 2021
STATUS

proposed

approved

Discussion
Wed Mar 24
22:15
OEIS Server: Installed new b-file as b045887.txt.  Old b-file is now b045887_1.txt.
#24 by Sean A. Irvine at Wed Mar 24 21:24:26 EDT 2021
STATUS

editing

proposed

Discussion
Wed Mar 24
21:31
Sean A. Irvine: @David no 024 should not be counted but 12 and 14 should be counted: 0, 2, 4, 12, 14, 24, 102. Note that A342845(1024)=6 from 0, 2, 4, 10, 24, 102.
21:35
Sean A. Irvine: a(1024) = 10 from 0, 2, 4, 10, 12, 14, 24, 102, 105, 124.
21:35
Sean A. Irvine: Ugh, I meant 104 not 105.
21:44
David A. Corneth: I see. Thanks Sean.
21:45
David A. Corneth: would a record sequence be interesting? and maybe a least k such that this = n sequence?
22:03
Sean A. Irvine: I just tried the records thing and it might be interesting as it seems irregular: 0, 1, 2, 4, 5, 6, 8, 10, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, 32, 34, 36, 38, 40, 42, 44, 46, 47, 50, 52, 54, 56, 57, 58, 60, 61, 62, 63, 68 ...  I computed as far as a(13524680)=247 in a few minutes. Does not appear to be already present in the OEIS.
#23 by Michael S. Branicky at Wed Mar 24 20:27:17 EDT 2021
PROG

(Python)

from itertools import combinations

def a(n):

s, eset = str(n), set()

for i in range(len(s)):

for j in range(i+1, len(s)+1):

if s[j-1] in "02468":

if len(s[i:j]) <= 2 and j-i < len(s):

eset.add(int(s[i:j]))

else:

middle = s[i+1:j-1]

for k in range(len(middle)+1):

for c in combinations(middle, k):

t = s[i] + "".join(c) + s[j-1]

if len(t) < len(s):

eset.add(int(t))

return len(eset)

print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 24 2021

Discussion
Wed Mar 24
20:27
Michael S. Branicky: Subsequence program.  Not pretty, but it matches your entire b-file!
21:17
David A. Corneth: I can comfirm examples but I get a(1024) = 6 via 0, 2, 4, 10, 24, 102. Should 024 be counted there too?
21:24
Sean A. Irvine: Summary: Two different sequences can be produced depending on whether the substrings considered are required to be contiguous or not, with the first difference occurring at term 101 (for odd) or 102 (for even). The original example in A045887 implied non-contiguous selections were allowed, but subsequent changes assumed contiguous. New sequences have been constructed for the contiguous case and the originals retained for the non-contiguous cases.  Comments, b-files, programs have been assigned to whichever sequence is appropriate. All four cases (even, odd, contiguous, non-contiguous) now have b-files independently verified by myself and Michael. In addition the originals now use "subsequence" rather than "substring" terminology.
#22 by Sean A. Irvine at Wed Mar 24 18:04:55 EDT 2021
NAME

Number of distinct even numbers visible as proper substrings subsequences of n.

LINKS

Reinhard Zumkeller, Sean A. Irvine, <a href="/A045887/b045887_1.txt">Table of n, a(n) for n = 0..10000</a> [Corrected by _Sean A. Irvine_, Mar 23 2021]

PROG

(Haskell)

import Data.List (isInfixOf)

a045887 n = length $ filter (`isInfixOf` (show n)) $ map show [0, 2..n-1]

-- Reinhard Zumkeller, Jul 19 2011

CROSSREFS
Discussion
Wed Mar 24
18:06
Sean A. Irvine: The contiguous interpretation (as used by Reinhard) is now A342845.
#21 by Michael S. Branicky at Wed Mar 24 00:36:21 EDT 2021
PROG

(Python)

def a(n):

s, eset = str(n), set()

for i in range(len(s)):

for j in range(i+1, len(s)+1):

if s[j-1] in "02468" and j-i < len(s): # even and proper substring

eset.add(int(s[i:j]))

return len(eset)

print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 23 2021

Discussion
Wed Mar 24
01:34
Sean A. Irvine: Maybe "subsequence" would be a better word than "substring" because I agree that "substring" would usually imply contiguous.
04:39
Sean A. Irvine: Cf. A094837, A094824 for similar distinction between subsequence and substring.  I think we should make new sequences for the (contiguous) substring situation, that way we can copy Reinhard's code across as appropriate.
08:19
Michael S. Branicky: Good idea!  I'd be willing be help you create the new ones.
12:31
Michael S. Branicky: Sean, For reference on notation, same Haskell page uses "subsequence":   "The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively."
#20 by Michael S. Branicky at Wed Mar 24 00:15:11 EDT 2021
PROG

if s[i] != "0" or j-i == 1: # don't count if starts with 0 and not 0

eset.add(int(s[i:j]))

Discussion
Wed Mar 24
00:15
Michael S. Branicky: a little shorter program here and in odd version
00:35
Michael S. Branicky: Given the a(124) example is original, I'll remove my program.  But Reinhard interpreted as I did (see isInfixOf at https://hackage.haskell.org/package/base-4.14.1.0/docs/Data-List.html), so perhaps a comment defining substring's interpretation here is warranted.
#19 by Michael S. Branicky at Tue Mar 23 23:51:45 EDT 2021
PROG

(Python)

def a(n):

s, eset = str(n), set()

for i in range(len(s)):

for j in range(i+1, len(s)+1):

if s[j-1] in "02468" and j-i < len(s): # even and proper substring

if s[i] != "0" or j-i == 1: # don't count if starts with 0 and not 0

eset.add(s[i:j])

return len(eset)

print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 23 2021

STATUS

proposed

editing

Discussion
Tue Mar 23
23:55
Michael S. Branicky: Hey, Sean, I just posted a program that agrees with Reinhard's full b-file.  I think the difference is how I read the definition of substring as contiguous versus a subsequence.  So a(102) = 3 since we can form 10, 0, 2;  "02" is not counted".
#18 by Sean A. Irvine at Tue Mar 23 23:22:38 EDT 2021
STATUS

editing

proposed

#17 by Sean A. Irvine at Tue Mar 23 23:22:35 EDT 2021
NAME

Number of distinct even numbers visible as proper substrings of n.

STATUS

proposed

editing