traBolics
traBolics

Reputation: 89

Equation of 1 22 333 4444 55555 sequence?

i need to find 1 22 333 sequence formula/equation.

I write this code for getting number like that but i need to find equation of this sequence

Code:

for (int i = 1; i <= 9; i++)
{
    for (int j = 0; j < i; j++)
    {
        Console.Write(i);
    }

    Console.Write("\n");
}

With this code I get this results

1
22
333
4444
55555
666666
7777777
88888888
999999999

Also Latex code line should works for me to.

I mean equation somethings like this for example:

example equation

Upvotes: -4

Views: 17448

Answers (4)

Penny Liu
Penny Liu

Reputation: 17388

The pattern can be implemented in Python using:

for x in range(1, 10):
    print((pow(10, x) // 9) * x)

Explanation:

  1. pow(10, x) or 10 ** x:

Raises 10 to the power of x, producing numbers like: 10^1 = 10, 10^2 = 100, 10^3 = 1000

  1. // 9:

Divides 10^x by 9 using integer division, generating a number consisting of x repetitions of the digit 1: 10^1 // 9 = 1, 10^2 // 9 = 11, 10^3 // 9 = 111

  1. * x:

Multiplies the result by x, forming the repetitive pattern: For x = 3: 111 * 3 = 333

Output:

1
22
333
4444
55555
666666
7777777
88888888
999999999

Upvotes: 0

Nissim Levy
Nissim Levy

Reputation: 57

Sn= 1/1458 * ((18n−2)10^(n+1)−81n^2−81n+20)

The above formula is correct for the scenario where the nth term of the series is n multiplied by a number comprised of n ones. So the tenth term is not ten zeroes, it's 10(1111111111) then 11(11111111111) etc..

Upvotes: 0

user448810
user448810

Reputation: 17851

The number a(n) that consists of n concatenated to itself n times is , where D(n) is the number of digits of n. This is a well-known Smarandache Sequence.

Upvotes: 0

Bathsheba
Bathsheba

Reputation: 234635

From the sum of a geometric progression, the value of the (n)th term is

n*(power(10, n) - 1)/9

where power(a, b) raises a to the bth power.

Upvotes: 5

Related Questions