Re: Finding the position of the number



On Tue, 30 May 2006 16:03:19 -0400, quasi <quasi@xxxxxxxx> wrote:

On 30 May 2006 12:44:08 -0700, "Pubkeybreaker"
<Robert_silverman@xxxxxxxxxxxx> wrote:


Atrus wrote:
Is there any formula that I could use that would find the position of a
number in a large sequence of numbers.

For example to find ' 11 ' in the string of numbers 1234567891011, some
formula would return the number 12, does anyone know of a formula that
would do this?

Thanks!

This has got to rank as one of the most clueless questions I've
ever seen within this newgroup. And I've been reading it for over
20 years.

Of course there's no method that would work in general, except for
brute force search. Even then, assuming the substring does not exist,
how would you know when to stop?

However for the _specific_ infinite string given above:

12345678910111213...

it's a reasonable to ask if there are formulas for

f(s) = the first location of a given substring s

c(s) = the canonical location of a given substring s

Thus, for example:

f(12)=2

c(12)=14

If not a formula, then at least a procedure which is faster than brute
force search.

quasi

For a given positive integer n, let s(n) be the base 10 string
representation of n, and let c(n) be the location of the canonical
occurrence of s(n) as a substring of the infinite string
12345678910111213...

Then c(n) is given by the formula:

c(n) = n*k(n) - ((10^k(n) - 10)/9)

where k(n) = floor(log_10(n)) + 1

quasi
.



Relevant Pages

  • Re: Finding the position of the number
    ... In message, quasi writes ... f= the first location of a given substring s ... c= the canonical location of a given substring s ... Note that cis only defined if s has no leading zero digits, ...
    (sci.math)
  • Re: two questions on infinite substrings of decimal strings....
    ... since this substring must start at a finite ... could any other finite sequence. ... say this when we look at the infinite string "123456...". ...
    (sci.math)
  • Re: Finding the position of the number
    ... In message, quasi writes ... f= the first location of a given substring s ... c= the canonical location of a given substring s ... Note that cis only defined if s has no leading zero digits, ...
    (sci.math)