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: Sameer Khan

Sameer Khan's wiki page.

Sameer Khan has authored 4 sequences.

A382482 a(1) = 1. Let a(n) be the most recently defined term. At each step, check for an undefined term with index < n. If such a term exists, then where i is the earliest such index, set a(i) = a(n) - (n - i). If no such term exists, then where i is the first undefined index >= n + a(n), set a(i) = the smallest integer not yet used.

Original entry on oeis.org

1, 2, 2, 3, 4, 2, 5, 6, 5, 5, 4, 7, 6, 5, 8, 9, 8, 5, 10, 11, 11, 4, 13, 13, 12, 15, 6, 12, 7, 13, 8, 14, 17, 16, 7, 19, 16, 19, 21, 18, 8, 23, 20, 20, 7, 21, 8, 22, 25, 22, 11, 27, 22, 11, 29, 24, 24, 12, 23, 14, 24, 31, 16, 26, 33, 26, 28, 16, 26, 30, 35
Offset: 1

Author

Sameer Khan, Mar 28 2025

Keywords

Comments

The sequence starts at 1 and is defined by two alternating rules:
(1) Where there are undefined terms that appear earlier in the sequence than the most recently defined term, populate the earliest undefined term by taking the most recently defined term and subtracting the difference between their indexes.
(2) Otherwise, move ahead a distance equal to the value of the most recently defined term and populate the first undefined term on or after that index with the smallest unused positive integer.
The sequence calculates terms in a non-sequential order, and so the n-th term of the sequence is generally not the n-th term to be calculated.
The sequence is infinite, but for any calculated length greater than nine terms (1, 2, 2, 3, 4, 2, 5, 6, 5), there will be undefined terms occurring before further defined terms; the sequence leaves gaps as part of its generation. These gaps will eventually get filled if generation continues, although new gaps will always exist.
The scatter plot is of interest, especially when looking at the first 1000 to 2000 terms. There are two distinct lines from the origin (illustrating the back filling and forward jumping nature of the sequence), but each of these lines occasionally splits into two separate lines before converging again, in a non-uniform manner and unrelated to each other.

Examples

			In the examples, missing terms are denoted by the "_" character and the most recently defined term is denoted as a(n).
Starting at n = 1 and a(1) = 1, the next n is therefore 1 + 1 = 2, with a(2) = 2 (the smallest unused positive integer):
n    1 2
a(n) 1 2
There are no missing terms, so using n = 2 and a(2) = 2, the next n is 2 + 2 = 4, with a(4) = 3:
n    1 2 3 4
a(n) 1 2 _ 3
There is now a single missing term at index 3, so that is the next n. It is 1 step back from the previous n, so a(3) = 3 - 1 = 2.
n    1 2 3 4
a(n) 1 2 2 3
There are no missing terms, so using n = 3 and a(3) = 2, the next n is 3 + 2 = 5, with a(5) = 4:
n    1 2 3 4 5
a(n) 1 2 2 3 4
There are no missing terms, so using n = 5 and a(5) = 4, the next n is 5 + 4 = 9, with a(9) = 5:
n    1 2 3 4 5 6 7 8 9
a(n) 1 2 2 3 4 _ _ _ 5
There are now missing terms, the earliest of which being at index 6, so that is the next n. It is 3 steps back from the previous n, so a(6) = 5 - 3 = 2:
n    1 2 3 4 5 6 7 8 9
a(n) 1 2 2 3 4 2 _ _ 5
		

Programs

  • Python
    requiredTerms = 100
    sequence = [None] * (requiredTerms*2)
    k,v = 0,1
    max = 0
    while True:
        sequence[k] = v
        if (v > max):
            max = v
        u = sequence.index(None)
        if u >= requiredTerms:
            break
        elif u < k:
            # advance backward, and decrement v by that much too
            d = k - u
            (k, v) = (k - d, v - d)
        else:
            # skip forward v, then advance to the next unfilled position
            (k, v) = (sequence.index(None, k + v), max + 1)
    for result in range(requiredTerms):
        print(sequence[result])

A375925 Squares visited by a king moving on a walled, spirally numbered board, where a wall must be jumped on each move, always to the lowest available unvisited square.

Original entry on oeis.org

1, 4, 14, 3, 11, 2, 8, 22, 7, 19, 5, 15, 33, 13, 29, 12, 28, 10, 24, 9, 23, 45, 21, 41, 20, 6, 18, 38, 17, 35, 16, 34, 60, 32, 58, 31, 55, 30, 54, 86, 52, 26, 48, 25, 47, 77, 46, 76, 44, 74, 43, 71, 42, 70, 40, 68, 39, 67, 37, 63, 36, 62, 96, 61, 95, 59, 93
Offset: 1

Author

Sameer Khan, Sep 03 2024

Keywords

Comments

The board is numbered with the following walled, square spiral:
.
17 16 15 14 13 | .
------------- | .
18 | 5 4 3 |12 | .
| ----- | | .
19 | 6 | 1 2 |11 | .
| --------- | .
20 | 7 8 9 10 | .
----------------- .
21 22 23 24 25 26
.
The walls mark the boundary of the spiral.
A line drawn from the center of the starting square of a king move to the center of the ending square must pass through a wall. The king jumps over that wall. Some moves would just touch a wall without passing through the wall (e.g. 1 to 3). Such moves are not permissible.
The rules imply that the king cannot move from a square labeled k in the spiral to a square labeled k +- 1 or k +- 2.
Comment from M. F. Hasler, May 08 2025 (Start)
The sequence appears to be a permutation of the positive integers. The path drawn by Kevin Ryde shows the quasi-periodic structure of the trajectory and may lead to a formal proof.
However, it would be more natural to start the path at the origin, at a square labeled n = 0 (to which the king never moves). Then the sequence would conjecurally be a permutation of the nonnegative integers. This also leads to a more natural numbering for the squares in terms of the x,y coordinates - compare the Python function "square_number()". See A383185. (End) [Comment edited by N. J. A. Sloane, May 14 2025 following discussion with Kevin Ryde.]

Examples

			For n = 2, a(2) = 4 because moving to 2 or 3 does not pass through a wall.
		

Crossrefs

Cf. A033638, A316667 (trapped knight), A336038 (trapped king).
Cf. A383185 (zero-indexed variant), A316328 (knight's path).

Programs

  • Python
    def square_number(z): return int(4*y**2-y-x if (y := z.imag) >= abs(x := z.real)
        else 4*x**2-x-y if -x>=abs(y) else (4*y-3)*y+x if -y>=abs(x) else (4*x-3)*x+y)
    def A375925(n):
        if not hasattr(A:=A375925, 'terms'): A.terms=[1]; A.pos=0
        while len(A.terms) < n:
            s,d = min((s,d) for d in (1, 1+1j, 1j, 1j-1, -1, -1-1j, -1j, 1-1j) if
                abs((s:=1+square_number(A.pos+d))-A.terms[-1]) > 2 and s not in A.terms)
            A.terms.append(s); A.pos += d
        return A.terms[n-1] # M. F. Hasler, May 07 2025

Formula

a(n) = A383185(n-1)+1. - M. F. Hasler, May 12 2025

Extensions

Entry revised by N. J. A. Sloane, May 12 2025

A372696 For n>1, if n mod a(n-1) = 0 or a(n-1) mod n = 0, set a(n) = n + a(n-1); otherwise a(n) = abs(n - a(n-1)). Start with a(1)=1.

Original entry on oeis.org

1, 3, 6, 2, 3, 9, 2, 10, 1, 11, 22, 10, 3, 11, 4, 20, 3, 21, 2, 22, 1, 23, 46, 22, 3, 23, 4, 32, 3, 33, 2, 34, 1, 35, 70, 34, 3, 35, 4, 44, 3, 45, 2, 46, 1, 47, 94, 46, 3, 47, 4, 56, 3, 57, 2, 58, 1, 59, 118, 58, 3, 59, 4, 68, 3, 69, 2, 70, 1, 71, 142, 70, 3
Offset: 1

Author

Sameer Khan, May 10 2024

Keywords

Comments

Starting at n=5, the sequence follows a set pattern every 12 terms: a(n) = n-2, 3, n-3, 4, n+4, 3, n+3, 2, n+2, 1, n+1, 2n according as n == 0 to 11 (mod 12), respectively.
This means a new peak is reached every 12th term, starting from n = 11.

Examples

			For a(2), as a(1) = 1 and n = 2 and 2 mod 1 = 0, use 2+1 = 3.
For a(3), as a(2) = 3 and n = 3 and 3 mod 3 = 0, use 3+3 = 6.
For a(4), as a(3) = 6 and n = 4 and 6 mod 4 != 0 and 4 mod 6 != 0, use abs(4-6) = 2.
		

Programs

  • Mathematica
    Block[{n = 1}, NestList[If[Divisible[++n, #] || Divisible[#, n], n + #, Abs[n - #]] &, 1, 100]] (* Paolo Xausa, May 20 2024 *)

A355140 n/d(n) rounded to the nearest integer, where d(n) is the number of divisors of n (A000005).

Original entry on oeis.org

1, 1, 2, 1, 3, 2, 4, 2, 3, 3, 6, 2, 7, 4, 4, 3, 9, 3, 10, 3, 5, 6, 12, 3, 8, 7, 7, 5, 15, 4, 16, 5, 8, 9, 9, 4, 19, 10, 10, 5, 21, 5, 22, 7, 8, 12, 24, 5, 16, 8, 13, 9, 27, 7, 14, 7, 14, 15, 30, 5, 31, 16, 11, 9, 16, 8, 34, 11, 17, 9, 36, 6, 37, 19, 13, 13, 19
Offset: 1

Author

Sameer Khan, Jun 20 2022

Keywords

Comments

In the ambiguous case, fractions are rounded up.

Examples

			a(1) = round (1 / 1) = 1;
a(4) = round (4 / 3) = 1;
a(5) = round (5 / 2) = 3;
		

Crossrefs

Cf. A000005, A078709 (floor), A334762 (ceiling), A090395 (numerators), A090387 (denominators).

Programs

  • Mathematica
    Table[Floor[n/DivisorSigma[0,n]+1/2],{n,100}] (* Harvey P. Dale, Dec 22 2022 *)
  • Python
    from sympy import divisor_count
    def A355140(n): return (2*n+(d:=divisor_count(n)))//(2*d) # Chai Wah Wu, Jun 20 2022

Formula

a(n) = round (n / A000005(n)).