cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A165370 Smallest number whose sum of cubes of digits is n.

Original entry on oeis.org

0, 1, 11, 111, 1111, 11111, 111111, 1111111, 2, 12, 112, 1112, 11112, 111112, 1111112, 11111112, 22, 122, 1122, 11122, 111122, 1111122, 11111122, 111111122, 222, 1222, 11222, 3, 13, 113, 1113, 11113, 2222, 12222, 112222, 23, 123, 1123, 11123
Offset: 0

Views

Author

Reinhard Zumkeller, Sep 17 2009

Keywords

Comments

A055012(a(n)) = n and A055012(m) <> n for m < a(n).
For all terms the digits are in nondecreasing order.
From Ondrej Kutal, Oct 06 2024: (Start)
a(n) can be formulated as a solution to an integer linear programming problem: Let c_i be the number of occurrences of digit i in the number (1 <= i <= 9). We want to minimize c_1 + c_2 + ... + c_9 (total number of digits) subject to the constraints c_1 + 8*c_2 + 27*c_3 + ... + 729*c_9 = n and c_i >= 0 for all i. To get the smallest solution among all with this number of digits, we further maximize the number of 1s (c_1), then the number of 2s (c_2), and so on up to 9s (c_9). This approach ensures we find the lexicographically smallest number with the minimum number of digits whose sum of cubes equals n.
a(n) can be computed by selecting a digit d (1 <= d <= 9) that minimizes the result of concatenating d with a(n-d^3), where n-d^3 >= 0. This can be done efficiently using dynamic programming.
As it turns out, the sequence is periodic (up to the trailing 9s) for n >= 4609, with a period of 729. Therefore, only a finite amount of values need to be computed; the rest can be derived by appending the appropriate number of 9s.
(End)

Crossrefs

Programs

  • PARI
    a(n) = my(k=1); while(vecsum(apply(x->(x^3), digits(k))) != n, k++); k; \\ Michel Marcus, Sep 08 2019
    
  • Python
    # using dynamic programming
    def A165370(n):
        # caching numbers,their tenth power (for fast concatenation) and cube sum
        cache = [(None, None, None)] * (n + 1)
        cache[0] = (0, 1, 0)
        cubes = [i**3 for i in range(10)]
        for i in range(1, min(n + 1, 5832)):
            for d in range(1, 10):
                if i - cubes[d] >= 0:
                    sub_result, tenthpower, cubesum = cache[i - cubes[d]]
                    if sub_result is not None:
                        current = d * tenthpower + sub_result
                        if cache[i][0] is None or current < cache[i][0]:
                            cache[i] = (current, 10 * tenthpower, cubesum + cubes[d])
        if n < 5832:
            return cache[n][0]
        sub_result, _, cubesum = cache[5103 + n % 729]
        nines = (n - cubesum) // 729
        return (sub_result + 1) * (10 ** nines) - 1 # Ondrej Kutal, Oct 06 2024

A259372 Smallest number whose sum of squares of some contiguous sectioning of it (into one or more parts) is n.

Original entry on oeis.org

0, 1, 11, 111, 2, 12, 112, 1112, 22, 3, 13, 113, 222, 23, 123, 1123, 4, 14, 33, 133, 24, 124, 233, 1233, 224, 5, 15, 115, 1115, 25, 125, 1125, 44, 144, 35, 135, 6, 16, 116, 1116, 26, 45, 145, 335, 226, 36, 136, 1136, 444, 7, 17, 117, 46, 27, 127, 1127, 246
Offset: 0

Views

Author

Hans Havermann, Jun 25 2015

Keywords

Comments

This sequence differs from A055016 beginning with a(100): A055016(100) = 68, whereas a(100) = 10.
a(n) = n for n = 0, 1, 101, 1233, ..

Examples

			10 may be sectioned into a single part, the (sum of the) square of which is 100. Because it is the smallest number to have a sum of 100, a(100) = 10.
101 may be sectioned into two parts, 10 and 1, the sum of the squares of which is 101. Because it is the smallest number to have a sum of 101, a(101) = 101.
3355 may be sectioned into 3, 35, and 5, the sum of the squares of which is 1259. Because it is the smallest number to have a sum of 1259, a(1259) = 3355.
		

Crossrefs

Cf. A055016.

Programs

  • Mathematica
    a[0]=0; a[n_] := Min[ FromDigits/@ Flatten/@ IntegerDigits@ Flatten[ Permutations/@ Sqrt[ IntegerPartitions[ n, {1, 5}, Range[ Sqrt@ n]^2 ]], 1]]; a/@ Range[0, 99] (* Giovanni Resta, Jun 26 2015 *)

A187553 Smallest prime p such that the sum of the squares of the digits of p equals n (or 0 if no such prime exists).

Original entry on oeis.org

0, 11, 0, 2, 101111, 211, 2111, 101111111, 3, 13, 113, 112121, 23, 21221, 1123, 11213, 41, 1223, 313, 10133, 241, 233, 112223, 21313, 5, 431, 151, 1151, 13313, 251, 2333, 11251, 2243, 53, 1433, 1153, 61, 523, 1523, 11161, 443, 541, 353, 33413, 2621, 163, 1163, 13523, 7, 17
Offset: 1

Views

Author

Michel Lagneau, Mar 26 2011

Keywords

Comments

a(3) = 0 because the numbers of the form 10..010..01 are divisible by 3. Conjecture : except for the numbers 1 and 3, for every possible square digit sum there exists a prime.

Examples

			a(13) = 23 because 2^2 + 3^2 = 13, and 23 is the least such prime.
		

Crossrefs

Programs

  • Maple
    with(numtheory):for k from 2 to 100 do: id:=0:for p from 1 to 100000 while(id=0)
      do:n:=ithprime(p):l:=length(n):n0:=n:s:=0:for m from 1 to l do:q:=n0:u:=irem(q,10):v:=iquo(q,10):n0:=v :s:=s+u^2:od: if s=k then id:=1:printf(`%d, `,n):else fi:od:od:
Showing 1-3 of 3 results.