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: M. F. Hasler

M. F. Hasler's wiki page.

M. F. Hasler has authored 2843 sequences. Here are the ten most recent ones:

A384102 Least x in absolute value, such that there exists y, |x| >= |y| > 0, such that n = |6xy + x + y|, or 0 if no such x exists. Choose x > 0 if x and -x are both possible.

Original entry on oeis.org

0, 0, 0, -1, 0, 1, 0, 1, -2, 0, 2, 0, -2, -3, 2, 3, 0, 0, -4, -2, 4, 3, 0, 2, 0, 5, -4, 2, 4, 0, -3, 0, 0, -5, 3, 5, -3, 0, -8, 0, 3, -4, 6, -9, 0, 4, 0, -3, -10, -4, 10, 0, -5, 3, -8, 11, 5, 0, -12, 3, 12, -9, -5, -6, -4, 13, 5, 6, -10, 0, 4, 0, -4, -15, -7, -6, 0, 11, 4, 6, 16, -5, -12, -17, 12, -8, 0, -4, -7, 8, 18, -5, 7, -19, 0, 4, -9, 5, -6
Offset: 1

Author

M. F. Hasler, Jun 20 2025

Keywords

Comments

(6n-1, 6n+1) are twin primes iff a(n) = 0, that is, if there are no nonzero integers x, y such that n = |6xy + x + y|. (These n are listed in A002822, the complement is A067611.)
a(n) <= (6*n-1)/5, with equality if 6*n+1 is prime and 6*n-1 is 5 times a prime. - Robert Israel, Jul 21 2025

Examples

			For n = 1, 2 and 3, there are no nonzero x,y such that n = |6xy + x + y|, and (6n-1, 6n+1) = (5, 7), (11, 13) and (17, 19) are indeed twin primes.
For n = 4 we have x = y = -1 such that |6xy + x + y| = |6 - 1 - 1| = 4 and (23, 25) is indeed not a twin prime pair.
		

Crossrefs

Cf. A384103 (the corresponding y-values).
Cf. A002822 (indices of zeros: n such that 6n-1 and 6n+1 are twin primes).
Cf. A077800 (list of twin primes), A060461, A171696 (none among 6n+-1 is prime), A067611 (n = 6xy +- x +- y: 6n-1 or 6n+1 is composite).

Programs

  • Maple
    f:= proc(n) local V, C, t, m,v, r;
           V:= numtheory:-divisors(6*n+1) minus {1,6*n+1};
           C:= map(u -> `if`(u mod 6 = 1,  [(u-1)/6, ((6*n+1)/u - 1)/6], [(-u-1)/6, (-(6*n+1)/u - 1)/6]), V);
           V:= numtheory:-divisors(6*n-1) minus {1,6*n-1};
           C:= C union map(u -> `if`(u mod 6 = 1, [(u-1)/6, ((-6*n+1)/u - 1)/6], [(-u-1)/6, ((-6*n+1)/u - 1)/6]), V);
           C:= select(t -> abs(t[1]) >= abs(t[2]), C)[..,1];
           if C = {} then return 0 fi;
           m:= infinity;
           for t in C do
             if abs(t) < m then m:= abs(t); r:= t;
             elif abs(t) = m and t > 0 then r:= t
             fi
           od;
           r
     end proc:
    map(f, [$1..100]); # Robert Israel, Jul 21 2025
  • PARI
    {A384102(n)=for(x=1,n\/5, my(p=6*x+1, q=6*x-1, r=if((n-x)%p==0, (n-x)\p, (n+x)%p==0, (n+x)\p, (n-x)%q==0, (x-n)\q, (n+x)%q==0,-(n+x)\q)); r && abs(r) <= x && return(sign(r)*x))}

A384103 a(n) = y with minimum |x| >= |y| > 0, such that n = |6xy + x + y|, or 0 if no such x, y exist. If x and -x are solutions, choose x > 0 > y = -x.

Original entry on oeis.org

0, 0, 0, -1, 0, -1, 0, 1, -1, 0, -1, 0, 1, -1, 1, -1, 0, 0, -1, -2, -1, 1, 0, -2, 0, -1, 1, 2, 1, 0, -2, 0, 0, 1, -2, 1, 2, 0, -1, 0, 2, -2, 1, -1, 0, -2, 0, -3, -1, 2, -1, 0, -2, -3, 1, -1, -2, 0, -1, 3, -1, 1, 2, -2, -3, -1, 2, -2, 1, 0, -3, 0, 3, -1, -2, 2, 0, 1, 3, 2, -1, -3, 1, -1, 1, -2, 0, -4, 2, -2
Offset: 1

Author

M. F. Hasler, Jun 20 2025

Keywords

Comments

(6n-1, 6n+1) are twin primes iff a(n) = 0, that is, if there are no nonzero integers x, y such that n = |6xy + x + y|. These n are listed in A002822, the complement is A067611.
The corresponding x-values are listed in A384102.

Examples

			For n = 1, 2 and 3, there are no nonzero x,y such that n = |6xy + x + y|, and (6n-1, 6n+1) = (5, 7), (11, 13) and (17, 19) are indeed twin primes.
For n = 4 we have x = y = -1 such that |6xy + x + y| = |6 - 1 - 1| = 4 and (23, 25) is indeed not a twin prime pair.
		

Crossrefs

Cf. A384102 (the corresponding x-values).
Cf. A002822 (indices of zeros: n such that 6n-1 and 6n+1 are twin primes).
Cf. A077800 (list of twin primes), A060461, A171696 (none among 6n+-1 is prime), A067611 (n = 6xy +- x +- y: 6n-1 or 6n+1 is composite).

Programs

  • Maple
    f:= proc(n) local V, C, t, m, v, r;
           V:= numtheory:-divisors(6*n+1) minus {1, 6*n+1};
           C:= map(u -> `if`(u mod 6 = 1,  [(u-1)/6, ((6*n+1)/u - 1)/6], [(-u-1)/6, (-(6*n+1)/u - 1)/6]), V);
           V:= numtheory:-divisors(6*n-1) minus {1, 6*n-1};
           C:= C union map(u -> `if`(u mod 6 = 1, [(u-1)/6, ((-6*n+1)/u - 1)/6], [(-u-1)/6, ((6*n-1)/u - 1)/6]), V);
           C:= select(t -> abs(t[1]) >= abs(t[2]), C);
           if C = {} then return 0 fi;
           m:= infinity;
           for t in C do
             if abs(t[1]) < m then m:= abs(t[1]); r:= t[2];
             elif abs(t[1]) = m and t[1] > 0 then r:= t[2]
             fi
           od;
           r
     end proc:
    map(f, [$1..100]); # Robert Israel, Jul 21 2025
  • PARI
    apply( {A384103(n)=for(x=1,n\/5, my(p=6*x+1, q=6*x-1, y=if((n-x)%p==0, (n-x)\p, (n+x)%p==0, -(n+x)\p, (n-x)%q==0, (n-x)\q, (n+x)%q==0,-(n+x)\q)); y && abs(y) <= x && return(y))}, [1..90])

A384095 Numbers other than {10^a + 10^b + 1} and {10^a + 5*10^b, min(a, b) = 0} whose square has digit sum 9 and no trailing zero.

Original entry on oeis.org

9, 18, 39, 45, 48, 249, 318, 321, 348, 351, 549, 1149, 1761, 4899, 10149, 14499, 375501
Offset: 1

Author

M. F. Hasler, Jun 15 2025

Keywords

Comments

The definition excludes the two "regular" subsequences of A384094, namely A052216+1 = 3*A237424 and A133472 U A199685, which provide most of its terms.
Is it true that no number > 1049 = A215614(6) has a square with digit sum less than 9, other than the trivial 1 and 4?
The next term, if it exists, is a(18) > 10^8.
a(18) > 10^14 if it exists. - Robert Israel, Jun 15 2025
a(18) > 10^40 if it exists. - Chai Wah Wu, Jun 19 2025

Crossrefs

Cf. A004159 (sum of digits of n^2), A384094 (sumdigits(n^2) = 9), A133472 (10^n+5), A199685 (5*10^n + 1), A052216 (10^a+10^b), A237424 ((10^a+10^b+1)/3).
See also: A215614 (sumdigits(n^2) = 7), A058414 (digits(n²) ⊂ {0,1,4}).

Programs

  • Maple
    extend:= proc(a,d) local i,s;
        s:= convert(convert(a,base,10),`+`);
        op(select(t -> numtheory:-quadres(t,10^d)=1, [seq(i*10^(d-1)+a, i=0 .. 9 - s)]))
    end proc:
    istriv:= proc(n) local L;
       L:= subs(0=NULL,convert(n,base,10));
       member(L, [[4],[5],[6],[1,1],[1,1,1],[1,2],[2,1],[1,5],[5,1]])
    end proc:
    R:= NULL:
    A:= [1,4,5,6,9]:
    for d from 2 to 20 do
      A:= map(extend,A,d);
      V:= select(t -> t > 10^(d-1) and issqr(t) and convert(convert(t,base,10),`+`)=9, A);
      if V <> [] then V:= sort(remove(istriv,map(sqrt,V))); R:= R,op(V); fi
    od:
    R;# Robert Israel, Jun 15 2025
  • PARI
    select( {is_A384095(n)=n%10 && sumdigits(n^2)==9 && !bittest(36938, fromdigits(Set(digits(n))))}, [1..10^5])

A384094 Numbers whose square has digit sum 9 and no trailing zero.

Original entry on oeis.org

3, 6, 9, 12, 15, 18, 21, 39, 45, 48, 51, 102, 105, 111, 201, 249, 318, 321, 348, 351, 501, 549, 1002, 1005, 1011, 1101, 1149, 1761, 2001, 4899, 5001, 10002, 10005, 10011, 10101, 10149, 11001, 14499, 20001, 50001, 100002, 100005, 100011, 100101, 101001, 110001, 200001, 375501, 500001, 1000002
Offset: 1

Author

M. F. Hasler, Jun 15 2025

Keywords

Comments

All numbers of the form 10^a + 10^b + 1 (i.e., A052216+1 = 3*A237424) and of the form 10^a + 5*10^b with min(a, b) = 0 (i.e., A133472 U A199685), are in this sequence. Terms not of this form are (9, 18, 39, 45, 48, 249, 318, 321, 348, 351, 549, 1149, 1761, 4899, 10149, 14499, 375501, ...), see subsequence A384095. (Is this sequence finite? What is the next term?)
Is it true that no number > 1049 = A215614(6) has a square with digit sum less than 9, other than the trivial 1 and 4?

Crossrefs

Cf. A004159 (sum of digits of n^2), A215614 (sumdigits(n^2) = 7), A133472 (10^n + 5), A199685 (5*10^n + 1), A052216 (10^a + 10^b), A237424 ((10^a + 10^b + 1)/3).
See also: A058414 (digits(n^2) in {0,1,4}).

Programs

  • PARI
    select( {is_A384094(n)=n%10 && sumdigits(n^2)==9}, [1..10^5])

A383182 a(n) = 2^n - A129629(n+1).

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 1, 5, 1, 1, 9, 1, 4, 16, 1, 1, 33, 11, 1, 65, 1, 1, 142, 1, 8, 257, 1, 35, 513, 1, 1, 1038, 67, 1, 2049, 1, 1, 4220, 39, 1, 8192, 1, 259, 16385, 1, 71, 32769, 515, 1, 65550, 1, 1, 132211, 1, 1, 262145, 1, 2051, 524302, 263, 32, 1048577, 4096, 1, 2097153, 1, 519, 4202480, 1, 1
Offset: 0

Author

M. F. Hasler, May 27 2025

Keywords

Comments

We observe that 2^(n-1) - A129629(n) often equals 1, and otherwise this difference is often the sum of only one or two distinct powers of two.

Crossrefs

Cf. A129629.

Programs

A384100 a(n) is the least positive x such that x^3 + x + n^2 is a perfect square, or 0 if no such x exists.

Original entry on oeis.org

0, 72, 4128, 8, 262272, 1000200, 44, 7529928, 16777728, 34012872, 64000800, 113380872, 191104128, 308917128, 12, 729001800, 4, 1544806728, 32, 3010939272, 4096003200, 8, 7256317728, 9474301128, 80, 15625005000, 19770615072, 24794917128, 30840985728, 38068699272
Offset: 0

Author

M. F. Hasler, May 19 2025

Keywords

Comments

Otherwise said, first component of the lexicographically earliest positive integer solution (x, y) to x^3 + x + n^2 = y^2. See A384101 for the second component, y.
For any positive n, there is always the solution (x, y) = (8*n^2*(8*n^4 + 1), n*(512*n^8 + 96*n^4 + 3)). Therefore 0 < a(n) <= 8*n^2*(8*n^4 + 1) for all n > 0.
We remark that n = 3 and n = 6 are the only cases below n = 10 for which there is a smaller solution than S(n) = (x, y) given above, while gcd(x, y) = gcd(n, 3) (= 3 iff n is divisible by 3, otherwise 1).

Examples

			For n = 0, there can't be any positive x for which x^3 + x = x*(x^2 + 1) = y^2, therefore a(0) = 0. (Indeed, x^2 + 1 == 1 (mod x), so x has no factor in common with x^2 + 1 = y^2/x, so x must be a square itself, x = m^2. But then, x^2 + 1 = (y/m)^2 can't have a solution, since x^2 + 1 can't be a square.)
For n = 1, we can check that for x = 1, 2, 3, ..., value of x^3 + x + 1 = 3, 10, 31, ... isn't a square for any x < 72 which is the least positive integer so that x^3 + x + 1 = 72*(72^2 + 1) + 1 = 373321 = (13*47)^2 is a perfect square, thus a(1) = 72.
For n = 2, there is no x < 4128 for which x^3 + x + 2^2 is a square, but 4128*(4128^2+1) + 4 = (2*132611)^2 is indeed the least square of that form, so a(2) = 4128. (As for n = 1, this is the upper limit for a(n), given in FORMULA.)
For n = 3, there is a(3) = x = 8 for which x^3 + x + 3^2 = 529 = 23^2 is a square, much smaller than the upper limit for a(n).
		

Crossrefs

Cf. A384101 (the corresponding y-values).

Programs

  • PARI
    apply({A384100(n)=for(x=1, 64*n^6+8*n^2, issquare(n^2+x^3+x) && return(x))}, [0..6])

Formula

a(n) <= 8*n^2*(8*n^4 + 1) for all n > 0.

Extensions

More terms from Jinyuan Wang, May 26 2025

A383184 Diamond spiral numbers of the grid points visited by a king always moving to the unvisited point labeled with the smallest possible prime or else composite number.

Original entry on oeis.org

0, 2, 3, 11, 23, 4, 5, 13, 12, 24, 41, 61, 40, 59, 83, 60, 84, 113, 85, 86, 62, 25, 26, 43, 14, 1, 7, 17, 31, 8, 19, 9, 10, 37, 21, 20, 53, 34, 33, 18, 32, 71, 97, 127, 72, 73, 50, 49, 48, 47, 29, 6, 15, 16, 30, 69, 68, 67, 28, 27, 44, 89, 64, 63, 42, 87, 88, 149, 116, 115, 114, 146, 223, 182, 181, 144, 179, 112, 111, 110, 109, 58, 38, 22, 57, 56, 79, 107, 139, 80, 81, 82, 39
Offset: 0

Author

M. F. Hasler, May 13 2025

Keywords

Comments

The infinite 2D grid is labeled along a diamond spiral as shown in A305258, starting with 0 at the origin (0,0), where each "shell" contains the points with given taxicab or L1-norm, as follows:
. (y)
2 | 8 17
| / \ \
1 | 9 2 7 16
| / / \ \ \
0 | 10 3 0--1 6 15
| \ \ / /
-1 | 11 4--5 14
| \ /
-2 | 12--13
x: -2 -1 0 1 2 3
.
(This numbering, where the n-th "shell" has only 4n numbers, is "finer" than the square spiral numbering where the n-th shell has 8n numbers.)
The cursor is moving like a chess king to the von Neumann neighbor not visited earlier and labeled with the smallest prime number if possible, otherwise with the smallest possible composite number.
After the 92th move, the cursor is trapped in the point (-1,-3) labeled a(92) = 39. All eight neighbors were then already visited earlier, so the king has no more any possible move: see the "path plot" given in the links section.

Examples

			From the starting point (0,0) labeled a(0) = 0, the king can reach the point (0,1) labeled 2, which is the smallest possible prime number, so a(1) = 2.
Then the king can reach (-1,0) labeled 3 which is the next smaller prime number, so a(2) = 3. From there it can go to (-1,-1) labeled 11 = a(3), and so on.
The king reaches (1,7) and (1,-9) before getting trapped at (-1,-3) from where there is no more any unvisited point among the 8 neighbors.
		

Crossrefs

Cf. A383183 (same with square spiral numbering).
Cf. A305258 (more details about the diamond spiral).

Programs

  • Python
    from sympy import isprime
    def diamond_number(z):
        x, y = int(z.real), int(z.imag); d = abs(x)+abs(y)
        return 2*d*(d-1)+((x if y<0 else d+y)if x>0 else 2*d-x if y>0 else 3*d-y)
    def A383184(n, moves=(1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j)):
        if not hasattr(A:=A383184, 'terms'): A.terms=[0]; A.pos=0; A.path=[0]
        while len(A.terms) <= n:
            try: _,s,z = min((1-isprime(s), s, z) for d in moves if
                             (s := diamond_number(z := A.pos+d))not in A.terms)
            except ValueError:
                raise IndexError(f"Sequence has only {len(A.terms)} terms")
            A.terms.append(s); A.pos = z; A.path.append(z)
        return A.terms[n]
    A383184(999) # gives IndexError: Sequence has only 93 terms
    A383184.terms # shows the full sequence
    import matplotlib.pyplot as plt # this and following to plot the path:
    plt.plot([z.real for z in A383184.path], [z.imag for z in A383184.path])
    plt.show()

A384101 a(n) is the least positive integer y such that y^2 = x^3 + x + n^2 for some positive integer x, or 0 if no such y exists.

Original entry on oeis.org

0, 611, 265222, 23, 134316044, 1000300015, 292, 20662660277, 68722622488, 198364959099, 512009600030, 1207284678721, 2641831428132, 5429539323143, 44, 19683072900045, 18, 60717129072787, 182, 165216338968409, 262144307200060, 31, 618122334258242, 922190780558053
Offset: 0

Author

M. F. Hasler, May 19 2025

Keywords

Comments

Otherwise said, second component of the lexicographically earliest positive integer solution (x, y) to x^3 + x + n^2 = y^2. See A384100 for the first component, x.
For any positive n, there is always the solution (x, y) = (4*n^2*(16*n^4 + 2), 2*n*(16*n^4 + 1)(16*n^4 + 2) - n). Therefore we have the inequality given in formula.
a(n) is even if and only if n is even. - Chai Wah Wu, May 24 2025

Examples

			For n = 0, there can't be any positive x for which x^3 + x = x*(x^2 + 1) = y^2, therefore a(0) = 0. (Indeed, x^2 + 1 == 1 (mod x), so x has no factor in common with x^2 + 1 = y^2/x, so x must be a square itself, x = m^2. But then, x^2 + 1 = (y/m)^2 can't have a solution, since x^2 + 1 can't be a square.)
For n = 1, we can check that for x = 1, 2, 3, ..., value of x^3 + x + 1 = 3, 10, 31, ... isn't a square for any x < 72 which is the least positive integer so that x^3 + x + 1 = 72*(72^2 + 1) + 1 = 373321 = (13*47)^2 is a perfect square, thus a(1) = 13*47 = 611.
For n = 2, there is no x < 4128 for which x^3 + x + 2^2 is a square, but 4128*(4128^2+1) + 4 = (2*132611)^2 is indeed the least square of that form, so a(2) = 2*132611 = 265222. (As for n = 1, this is the upper limit for a(n), given in FORMULA.)
For n = 3, there is already x = 8 for which x^3 + x + 3^2 = 529 = 23^2 is a square, therefore a(3) = 23 is much smaller than the before mentioned upper limit.
		

Crossrefs

Cf. A384100 (the corresponding x-values).

Programs

  • PARI
    A384101(n, x=A384100(n))=sqrtint(n^2+x^3+x)
    
  • Python
    from math import isqrt
    from sympy.ntheory.primetest import is_square
    def A384101(n):
        if n==0: return 0
        m = n**2
        for x in range(1,n*(n**4*((n**4<<9)+96)+3)+1):
            if is_square(k:=x*(x**2+1)+m): return isqrt(k) # Chai Wah Wu, May 24 2025

Formula

0 < a(n) <= 2*n*(16*n^4 + 1)*(16*n^4 + 2) - n for all n > 0.

Extensions

a(9)-a(21) from Chai Wah Wu, May 24 2025
a(22)-a(23) from Jinyuan Wang, May 26 2025

A383189 Inverse permutation to A383187 (diamond spiral numbers of a king moving on the infinite two-dimensional grid, not to the point numbered a(n)+-1).

Original entry on oeis.org

0, 3, 1, 6, 4, 15, 13, 2, 9, 7, 20, 5, 16, 35, 14, 31, 12, 10, 25, 8, 21, 42, 19, 17, 36, 63, 34, 32, 57, 30, 11, 26, 49, 24, 22, 43, 72, 41, 18, 37, 64, 99, 62, 33, 58, 91, 56, 29, 27, 50, 81, 48, 23, 44, 73, 110, 71, 40, 38, 65, 100, 143, 98, 61, 59, 92, 133, 90, 55, 28, 51, 82, 121, 80
Offset: 0

Author

M. F. Hasler, May 12 2025

Keywords

Crossrefs

Cf. A383187 (inverse permutation).

Programs

  • Python
    def A383189(n):
        if not hasattr(A:=A383189, 'terms'): A.terms=[0]
        while len(t := A.terms) <= n:
           try: any(t.append(A383187.terms.index(k))for k in range(len(t), n+1))
           except: A383187(len(getattr(A383187,'terms',0)+100))
        return A.terms[n]

A383186 Inverse permutation to A383185 (square spiral numbers of king filling the two-dimensional grid always crossing the spiral's wall).

Original entry on oeis.org

0, 5, 3, 1, 10, 25, 8, 6, 19, 17, 4, 15, 13, 2, 11, 30, 28, 26, 9, 24, 22, 7, 20, 18, 43, 41, 74, 16, 14, 37, 35, 33, 12, 31, 29, 60, 58, 27, 56, 54, 23, 52, 50, 48, 21, 46, 44, 42, 79, 77, 75, 40, 73, 38, 36, 69, 67, 34, 65, 32, 63, 61, 59, 100, 98, 147, 57, 55, 94, 53, 51, 90, 88, 49, 86
Offset: 0

Author

M. F. Hasler, May 12 2025

Keywords

Crossrefs

Cf. A383185.

Programs

  • Python
    def A383186(n):
        if not hasattr(A:=A383186, 'terms'): A.terms=[0]; A.N=1
        while len(t := A.terms) <= n:
           try: any(t.append(A383185.terms.index(k))for k in range(len(t), n+1))
           except: A.N = A.N*5//4+99; A383185(A.N)
        return A.terms[n]