A000461: Concatenate n n times

https://oeis.org/A118115

Given the following:

1: 1
2: 23
3: 356
4: 4800
5: 60355
6: 727021
7: 8504798
8: 97393686
9: 1097393685
10: 10101010102107494695
11: 1121212121213218605806
12: 122333333333334430727018
13: 13253646464646465743858331
14: 1427395060606060607157999745

Formula: a(n) = Sum_{i=1…n} A000461(i). a(n) = Sum_{i=1…n} i*(10^(i*L(i))-1)/(10^L(i)-1) where L(i) = A004216(i) + 1 = floor(log_10(10i)).

Example for 5:

1 + 22 + 333 + 4444 + 55555
= 60355

I have written a PHP script to do this simply.

<?php
    $n = 14;
    $r = [];
    foreach (range(1, $n) as $e) {
        $d = str_repeat($e, $e);
        array_push($r, $d);
        $d = number_format(array_sum($r), 0, "", "");
        echo $e . ": " . $d . "\n";
    }
?>


Output result:

1: 1
2: 23
3: 356
4: 4800
5: 60355
6: 727021
7: 8504798
8: 97393686
9: 1097393685
10: 10101010102107494400
11: 1121212121213218586624
12: 122333333333334432940032
13: 13253646464646464531333120
14: 1427395060606060695451074560

The error begins at 10. I am assuming that the real answer for 10 would be 1097393685 + 10101010101010101010, but the answers do not match. I am unable to find an online calculator that does not have E. I am guessing that the PHP rounds up somewhere, but it doesn’t seem to be so.

have a look at the PHP_INT_MAX constant

https://www.php.net/manual/en/reserved.constants.php

1 Like

@chorn So, if there were no limit, this would theoretically work?

Sponsor our Newsletter | Privacy Policy | Terms of Service