Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A159860
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A159860 The maximum length of a string of identical characters which can be reduced to one character in "n" nested substitution operations, e.g. replace(string, substring, character) such that all shorter strings will also reduce to one character. +0
1
2, 4, 10, 40, 460, 53590, 718052410, 128899816953780640, 4313494300416744426870901874924164733839903365825579313972159982440, 46515582699319348549756200160043378760131350722231086030580973975939382315570416\ 44242694327255059535060293888049465758695393517062060 (list; graph; listen)
OFFSET

1,1

COMMENT

The ideal substring length is related to A007501. It can be shown these are equivalent problems.

For n = 1, the ideal substring length is 2.

For n > 1:

n = 2, term 0 of A007501, substring length = 2

n = 3, term 1 of A007501, substring length = 3

n = 4, term 2 of A007501, substring length = 6

etc.

This has applications in text processing operations in computer languages where recursions or loops may not be possible (e.g. standard SQL). To remove extra spaces, one might be tempted to nest several replace operations but use the same substring length, or perhaps double or halve at each step, both of which will not clear as effectively as using substring lengths as indicated in A007501.

FORMULA

Given substring length p as indicated in A007501, sequence is p(p+1)-2.

EXAMPLE

To illustrate, suppose we have a string of repeating Xs.

n = 1: replace(string, "XX", "X"), the longest string which will reduce to "X" is "XX"

n = 2: replace(replace(string, "XX", "X"), "XX", "X") will reduce up to 4 Xs to "X"

n = 3: replace(replace(replace(string, "XXX", "X"), "XX", "X"), "XX", "X") up to 10 Xs

n = 4: replace(replace(replace(replace(string, "XXXXXX", "X"), "XXX", "X"), "XX", "X"), "XX", "X") up to 40 Xs

etc.

PROGRAM

(Other) // q is this sequence, p is A007501

set q = 2

output q

repeat

set p = q / 2 + 1

set q = p * (p + 1) - 2

output q

end repeat

CROSSREFS

2, followed by A007501

Sequence in context: A086852 A084737 A153757 this_sequence A013549 A125805 A028404

Adjacent sequences: A159857 A159858 A159859 this_sequence A159861 A159862 A159863

KEYWORD

easy,nonn

AUTHOR

Russell Harper (russell.harper(AT)springboardnetworks.com), Apr 24 2009

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified December 17 13:29 EST 2009. Contains 170826 sequences.


AT&T Labs Research