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.

User: Thorsten Ehlers

Thorsten Ehlers's wiki page.

Thorsten Ehlers has authored 2 sequences.

A374020 Number of solutions to a^2 + d^2 = b^2 + c^2 with 1 <= a < b < c < d <= n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 4, 5, 7, 9, 10, 12, 15, 18, 23, 26, 29, 33, 39, 43, 48, 54, 60, 65, 74, 79, 87, 96, 105, 114, 122, 129, 140, 151, 162, 171, 185, 194, 210, 223, 233, 247, 264, 277, 293, 308, 323, 338, 360, 376, 392, 407, 425, 444, 468, 484
Offset: 1

Author

Thorsten Ehlers, Jun 25 2024

Keywords

Examples

			For n = 9 the a(9) = 2 solutions are 1^2 + 8^2 = 4^2 + 7^2 = 65 and 2^2 + 9^2 = 6^2 + 7^2 = 85.
For n = 18 three of the a(18) = 18 solutions sum up to 325: 1^2 + 18^2 = 6^2 + 17^2 = 10^2 + 15^2.
		

Programs

  • C
    #include 
    #define N    10000ULL
    typedef unsigned long long ull_t;
    ull_t Sums[2 * N * N];
    int main() {
        ull_t sol = 0;
        for (ull_t i = 1; i < N; i++)
            for (ull_t j = i + 1; j <= N; j++)
                sol += Sums[i * i + j * j]++;
        printf("%llu \n", sol);
    }
    
  • Python
    from itertools import count, islice
    from collections import Counter
    def A374020_gen(): # generator of terms
        c, s = 0, Counter()
        for n in count(1):
            n2 = n**2
            for i in range(1,n):
                c += s[m:=i**2+n2]
                s[m] += 1
            yield c
    A374020_list = list(islice(A374020_gen(),20)) # Chai Wah Wu, Jul 18 2024

A215669 Number of decimal digits of the smallest solution for the reverse-and-subtract problem for cycle length n.

Original entry on oeis.org

0, 4, 0, 18, 32, 0, 42, 44, 48, 24, 42, 12, 40, 8, 50, 368, 16, 100, 410, 118, 0, 12, 442, 584, 546, 1104, 482, 148, 2786, 536, 398
Offset: 1

Author

Thorsten Ehlers, Aug 20 2012

Keywords

Comments

Solution x for a given cycle length n for the reverse-and-subtract problem is defined as x = f^n(x), x <> f^j(x) for j < n, where f: k -> |k - reverse(k)|. For some cycle lengths (at least for 1, 3, 6 and 21) no solutions exist, these are marked as 0 in above sequence.
Zero cannot be considered a solution for cycle length 1 as there are nontrivial solutions for other numeral systems, such as 13 (one-three) in base 5 numeral system.
This is an excerpt which shows the smallest solutions with up to 50 digits only:
.n..#digits.....................................smallest.solution......ref
.2........4..................................................2178..A072141
.4.......18....................................169140971830859028..A292634
.5.......32......................10591266563195008940873343680499..A292635
.7.......42............142710354353443018141857289645646556981858..A292856
.8.......44..........16914079504181797053273763831171860502859028..A292857
.9.......48......111603518721165960373027269626940447783074704878..A292858
10.......24..............................101451293600894707746789..A292859
11.......42............166425621223026859056339052269787863565428..A292846
12.......12..........................................118722683079..A072718
13.......40..............1195005230033599502088049947699664004979..A292992
14........8..............................................11436678..A072142
15.......50....10695314508256806604321090888649339244708568530399..A292993
17.......16......................................1186781188132188..A072719
22.......12..........................................108811891188..A072143
Solutions for all cycle lengths up to 31 can be found below in the links section. Remember that a zero means there exists no solution for this specific cycle length.
There are two ways to find such solutions, first you can search in a given range of numbers e.g. from 10000000 to 99999999 and apply reverse-and-subtract to each number until you fall below the smallest number in this range (here: 10000000) or you find a cycle. Obviously, this works well only on small numbers up to 18-20 digits.
The second way is to construct a cycle with a given length n from the outside in until the innermost 2 digits of each number match the conditions for a valid cycle. This way it is possible to get the above results within seconds up to some hours depending on the specific cycle length even on an outdated PC.

Examples

			a(4) = 169140971830859028 as the smallest cycle with length 4 is 169140971830859028 -> 651817066348182933 -> 312535222687464777 -> 464929563535070436 ( -> 169140971830859028 ).
		

Extensions

Added a reference, formatted and added one more example in comments. - Thorsten Ehlers, Oct 06 2012
Sequences added to comments and crossrefs by Ray Chandler, Sep 27 2017