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: Ya-Ping Lu

Ya-Ping Lu's wiki page.

Ya-Ping Lu has authored 121 sequences. Here are the ten most recent ones:

A385613 Number of steps that n requires to reach 0 under the map: x-> x^2 - 1 if x is an odd prime, floor(x/3) if x is even, otherwise x - 1. a(n) = -1 if 0 is never reached.

Original entry on oeis.org

0, 1, 1, 3, 2, 4, 2, 7, 2, 3, 4, 9, 3, 6, 3, 4, 5, 8, 3, 10, 3, 4, 8, 14, 3, 4, 3, 4, 4, 10, 5, 15, 5, 6, 10, 11, 4, 10, 4, 5, 7, 8, 4, 14, 4, 5, 5, 10, 6, 7, 6, 7, 9, 15, 4, 5, 4, 5, 11, 9, 4, 18, 4, 5, 5, 6, 9, 10, 9, 10, 15, 9, 4, 22, 4, 5, 5, 6, 4, 11, 4
Offset: 0

Author

Ya-Ping Lu, Jul 04 2025

Keywords

Comments

n = 122827 is the smallest starting number that ends up in a loop. The loop contains 33 elements: 122827 -> 15086471928 -> 5028823976 -> 1676274658 -> 558758219 -> 558758218 -> 186252739 -> 186252738 -> 62084246 -> 20694748 -> 6898249 -> 47585839266000 -> 15861946422000 -> 5287315474000 -> 1762438491333 -> 1762438491332 -> 587479497110 -> 195826499036 -> 65275499678 -> 21758499892 -> 7252833297 -> 7252833296 -> 2417611098 -> 805870366 -> 268623455 -> 268623454 -> 89541151 -> 89541150 -> 29847050 -> 9949016 -> 3316338 -> 1105446 -> 368482 -> 122827.
No other loop is found for n < 164901049.
Conjecture: a(n) = -1 occurs only when starting number n runs into a loop.

Examples

			a(5) = 4 because iterating the map on n = 5 results in 0 in 4 steps: 5 -> 5^2-1=24 -> floor(24/3)=8 -> floor(8/3)=2 -> floor(2/3)=0.
a(9949031) = -1 because iterating the map on n = 9949031 ends up in the 33-member loop in 5 steps: 9949031 -> 9949030 -> 3316343 -> 3316342 -> 1105447 -> 1105446.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def A385613(n):
        S = {n}
        while n != 0:
            n = n//3 if n%2 == 0 else n*n - 1 if isprime(n) else n - 1
            if n in S: return -1
            S.add(n)
        return len(S) - 1

A384713 The number of steps that n requires to reach 1 under the map: x-> x^2 - 1 if x is an odd prime, x/2 if x is even, x - lpf(x) otherwise where lpf(x) is the least prime factor of x. a(n) = -1 if 1 is never reached.

Original entry on oeis.org

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

Author

Ya-Ping Lu, Jun 23 2025

Keywords

Comments

First 8 terms are the same as those in A339991.
Conjecture: a(n) != -1.

Crossrefs

Cf. A339991.

Programs

  • Python
    from sympy import isprime, primefactors
    def A384713(n, c = 0):
        while n != 1: n = n//2 if n%2 == 0 else n*n-1 if isprime(n) else n-min(primefactors(n)); c += 1
        return c

A384874 a(n) is the first prime encountered when iterating the map x -> x/2 if x is even, x*lpf(x) + 1 otherwise, where lpf(x) is the least prime factor of x, on n >= 2; or -1 if a prime is never reached.

Original entry on oeis.org

2, 3, 2, 5, 3, 7, 2, 7, 5, 11, 3, 13, 7, 23, 2, 17, 7, 19, 5, 2, 11, 23, 3, 313, 13, 41, 7, 29, 23, 31, 2, 313, 17, 11, 7, 37, 19, 59, 5, 41, 2, 43, 11, 17, 23, 47, 3, 43, 313, 5869, 13, 53, 41, 13, 7, 43, 29, 59, 23, 61, 31, 313, 2, 163, 313, 67, 17, 13, 11
Offset: 2

Author

Ya-Ping Lu, Jun 11 2025

Keywords

Comments

Conjecture: a(n) != -1.
For n <= 24, this sequence is the same as A320028.

Crossrefs

Programs

  • Python
    from sympy import isprime, primefactors
    def A384874(n):
        while not isprime(n): n = n*min(primefactors(n))+1 if n%2 else n//2
        return n

A384512 Record terms in A384698.

Original entry on oeis.org

2, 3, 13, 17, 37, 41, 61, 613, 829, 1861, 2269, 7333, 35149, 1008229, 909889549, 1423665384101, 10341624100573, 440171836495742615578609, 471206109194322691633610979351605854911441181, 4466501842784976704198682186832272945270823914876207595593007001786562643495541
Offset: 1

Author

Ya-Ping Lu, May 31 2025

Keywords

Examples

			41 is a term because iterating the map on 12 results in a prime in 3 steps: 12 -> 2*12+1=25 -> 25-5=20 -> 2*20+1=41 and 41 is a record prime for starting integers <= 12.
		

Crossrefs

Cf. A020639 (lpf), A383777, A384698.

Programs

  • Python
    from sympy import isprime, primefactors; rec = 1
    for n in range (2, 158163):
        while not isprime(n): n = n - min(primefactors(n)) if n%2 else 2*n + 1
        if n > rec: rec = n; print(n, end = ', ')

Formula

a(n) mod 4 = 1, n > 2.

A384698 The first prime number reached by iterating the map, x -> 2*x + 1 if x is even; x - lpf(x) otherwise where lpf(x) is the least prime factor of x, on n >= 2; or -1 if a prime is never reached.

Original entry on oeis.org

2, 3, 13, 5, 13, 7, 17, 13, 37, 11, 41, 13, 29, 41, 61, 17, 37, 19, 41, 37, 613, 23, 613, 41, 53, 613, 109, 29, 61, 31, 829, 61, 1861, 61, 73, 37, 277, 73, 157, 41, 613, 43, 89, 613, 181, 47, 97, 613, 101, 97, 401, 53, 109, 101, 113, 109, 229, 59, 829, 61, 241
Offset: 2

Author

Ya-Ping Lu, Jun 09 2025

Keywords

Comments

Conjecture: a(n) != -1.

Examples

			a(4) = 13 because iterating the map on n = 4 reaches a prime, 13, in three steps: 4 -> 2*4+1=9 -> 9-3=6 -> 2*6+1=13.
		

Crossrefs

Cf. A020639 (lpf), A383777.

Programs

  • Python
    from sympy import isprime, primefactors
    for n in range (2, 63):
        while not isprime(n): n = n - min(primefactors(n)) if n%2 else 2*n + 1
        print(n, end = ', ')

Formula

a(n) = n if n is a prime; > n otherwise.
a(n) mod 4 = 1 unless n is a prime and n mod 4 = 3.

A383777 a(n) is the number of steps that n requires to reach 0 under the map: x -> 2*x + 1 if x is even; 0 if x = 1; x - lpf(x) otherwise where lpf(x) is the least prime factor of x. a(n) = -1 if 0 is never reached.

Original entry on oeis.org

0, 1, 2, 1, 4, 1, 2, 1, 2, 3, 4, 1, 4, 1, 2, 5, 4, 1, 2, 1, 2, 3, 10, 1, 10, 3, 2, 11, 4, 1, 2, 1, 10, 3, 12, 3, 2, 1, 6, 3, 4, 1, 8, 1, 2, 9, 4, 1, 2, 9, 2, 3, 6, 1, 2, 3, 2, 3, 4, 1, 8, 1, 4, 9, 10, 9, 10, 1, 2, 11, 4, 1, 4, 1, 2, 5, 10, 5, 2, 1, 6, 3, 6, 1
Offset: 0

Author

Ya-Ping Lu, May 17 2025

Keywords

Comments

Conjecture: a(n) != -1.

Examples

			a(10) = 4 because it takes 4 steps for 10 to reach 1 by iterating the map: 10 -> 2*10+1=21 -> 21-3=18 -> 2*18+1=37 -> 37-37=0.
		

Crossrefs

Programs

  • Mathematica
    A383777[n_] := Length[NestWhileList[If[OddQ[#], # - FactorInteger[#][[1,1]], 2*# + 1] &, n, # >0 &]] - 1;
    Array[A383777, 100, 0] (* Paolo Xausa, May 22 2025 *)
  • Python
    from sympy import primefactors; mp = lambda x: (0 if x ==1 else x - min(primefactors(x)) if x%2 else 2*x+1)
    def A383777(n, c = 0):
        while n != 0: n = mp(n); c += 1
        return c

A382669 Even numbers m such that both p = m^2 + 1 and q = (p^2 + 1)/2 are primes.

Original entry on oeis.org

2, 10, 150, 160, 230, 270, 400, 890, 910, 920, 1060, 1430, 1550, 1970, 2700, 2960, 3280, 3290, 3520, 3660, 4140, 4330, 4510, 4700, 4780, 4850, 4920, 5180, 5360, 5500, 5560, 5620, 5880, 5960, 6220, 6460, 6980, 7160, 7190, 7520, 7550, 7820, 9630, 9760, 9900
Offset: 1

Author

Ya-Ping Lu, Apr 24 2025

Keywords

Comments

Except 2, all terms are divisible by 10, and p-1 and q-1 are divisible by 100.
Numbers m such that p = m^2+1 and p + m^4/2 are both prime. - Chai Wah Wu, May 01 2025

Examples

			10 is a term because both 10^2 + 1 = 101 and (101^2 + 1)/2 = 5101 are primes.
		

Crossrefs

Programs

  • Maple
    filter:= proc(m) local p;
      p:= m^2 + 1;
      isprime(p) and isprime((p^2+1)/2)
    end proc:
    select(filter, [2,seq(i,i=10..10000,10)]); # Robert Israel, May 02 2025
  • Mathematica
    Select[2*Range[5000], PrimeQ[#^2 + 1] && PrimeQ[#^4/2 + #^2 + 1] &] (* Amiram Eldar, Apr 24 2025 *)
  • Python
    from sympy import isprime
    for n in range(2, 10000, 2): x = n*n + 1; ct = 0; print(n, end = ', ') if isprime(x) and isprime((x*x + 1)//2) else 0
    
  • Python
    from itertools import count, islice
    from sympy import isprime
    def A382669_gen(): # generator of terms
        yield 2
        yield from filter(lambda m: isprime(p:=m**2+1) and isprime(p+(m**4>>1)),(10*k for k in count(1)))
    A382669_list = list(islice(A382669_gen(),45)) # Chai Wah Wu, May 02 2025

A383131 a(n) is the number of iterations that n requires to reach 1 under the map x -> -x/2 if x is even, 3x + 1 if x is odd; a(n) = -1 if 1 is never reached.

Original entry on oeis.org

0, 3, 12, 2, 5, 5, 8, 5, 11, 11, 50, 14, 14, 14, 53, 4, 17, 17, 43, 7, 7, 7, 20, 7, 46, 46, 59, 10, 10, 10, 23, 7, 49, 49, 62, 13, 13, 13, 13, 13, 26, 26, 39, 52, 52, 52, 65, 16, 16, 16, 78, 16, 16, 16, 29, 16, 42, 42, 55, 55, 55, 55, 68, 6, 19, 19, 19, 19, 19
Offset: 1

Author

Ya-Ping Lu, Apr 17 2025

Keywords

Comments

A plot of a(n) for non-zero integers n in the range of (-10000, 10000) is given in LINKS.
Conjecture: a(n) != -1 for any positive or negative integer n.

Examples

			a(3) = 12 because it takes 12 steps for n = 3 to reach 1: 3 -> 10 -> -5 -> -14 -> 7 -> 22 -> -11 -> -32 -> 16 -> -8 -> 4 -> -2 -> 1.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=1, 0,
          1+a(`if`(n::even, -n/2, 3*n+1)))
        end:
    seq(a(n), n=1..69);  # Alois P. Heinz, Aug 13 2025
  • Mathematica
    js[n_] := If[EvenQ[n],-n/2,3n+1]; f[n_] := Length[ NestWhileList[js, n, # != 1 &]] - 1; Table[ f[n], {n, 69}] (* James C. McMahon, Apr 30 2025 *)
  • PARI
    a(n) = { for (k = 0, oo, if (n==1, return (k), n = if (n%2, 3*n+1, -n/2));); } \\ Rémy Sigrist, Apr 19 2025
  • Python
    def A383131(n):
        ct = 0
        while n != 1: n = 3*n+1 if n%2 else -n>>1; ct += 1
        return ct
    

A381055 a(n) = -n/2 if n is even, 3n + 1 if n is odd.

Original entry on oeis.org

0, 4, -1, 10, -2, 16, -3, 22, -4, 28, -5, 34, -6, 40, -7, 46, -8, 52, -9, 58, -10, 64, -11, 70, -12, 76, -13, 82, -14, 88, -15, 94, -16, 100, -17, 106, -18, 112, -19, 118, -20, 124, -21, 130, -22, 136, -23, 142, -24, 148, -25, 154, -26, 160, -27, 166, -28, 172
Offset: 0

Author

Ya-Ping Lu, Apr 14 2025

Keywords

Comments

If negative indices are allowed, integers m = 0, 1, 2, 3, or 5 (mod 6) appear once (at n = -2*m) in the sequence, while integers m = 4 (mod 6) appear twice (at n = -2*m and (m-1)/3).
Conjecture: Iterating the map x -> a(x) on any negative or positive integer eventually reaches 1. Some iteration paths between -35 and 35 are illustrated in the plot of a(n) in LINKS.

Examples

			a(0) = -0/2 = 0; a(1) = 3*1 + 1 = 4; a(10) = -10/2 = -5.
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=If[EvenQ[n],-n/2,3n+1];Array[a,58,0] (* James C. McMahon, Apr 30 2025 *)
  • Python
    def A381055(n): return 3*n+1 if n%2 else -n>>1

Formula

a(n) = (-1)^(n+1)*A006370(n).
a(n) = (1/4)*((-1)^(n+1)*(7*n+2)+5*n+2).
G.f.: x*(2*x^2-x+4)/((x-1)^2*(x+1)^2). - Alois P. Heinz, Aug 13 2025

A381169 List of twin prime averages (A014574) is partitioned by including as many elements as possible in the n-th partition, L_n, such that any gap in L_n is smaller than the gap between L_n and L_(n-1) but not bigger than the first gap in L_n. a(n) is the number of elements in L_n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 2, 2, 1, 1, 2, 1, 6, 3, 2, 2, 2, 1, 1, 5, 2, 2, 2, 3, 1, 2, 2, 2, 2, 3, 2, 2, 1, 2, 4, 2, 2, 2, 2, 5, 2, 2, 1, 1, 1, 3, 2, 2, 1, 3, 3, 2, 1, 4, 2, 3, 2, 2, 1, 2, 2, 3, 3, 1, 3, 2, 1, 2, 1, 1, 2, 3, 3, 1, 1, 2, 2, 3, 2, 2, 1, 5, 2
Offset: 1

Author

Ya-Ping Lu, Feb 15 2025

Keywords

Comments

The partition method used here is the same as that in A348168.
Conjecture 1: lim_{n->oo} N_i/n = k_i, where N_i is the number of partitions with i elements and k_i is a constant, with k_2 > k_1 > k_3 > k_4 > .... The values of k_i are the same as those in A348168.
Conjecture 2: lim_{n->oo} Sum_{1..n} a(n)/n = lim_{i->oo} Sum_{1..i} i*k_i = e, or the average partition length approaches 2.71828... as n tends to infinity.
Numbers of twin prime pairs (N) and partitions with 1 through 6 twin prime pairs for n up to 10000000 are given in the table below.
n N N_1 N_2 N_3 N_4 N_5 N_6
-------- -------- ------- ------- ------- ------ ------ ------
1 1 1 0 0 0 0 0
10 15 6 3 1 0 0 0
100 209 30 45 16 5 3 1
1000 2536 286 416 145 64 29 19
10000 26474 2851 4331 1271 544 311 190
100000 271338 28034 43375 12923 5731 3002 1870
1000000 2725126 281837 434234 128190 56563 30074 18171
10000000 27120107 2815831 4352926 1276953 563128 302256 181612

Examples

			Twin prime pair averages in the first 10 partitions are: [4], [6], [12], [18], [30], [42], [60, 72], [102, 108], [138, 150], and [180, 192, 198]. Thus, a(1) = a(2) = a(3) = a(4) = a(5) = a(6) = 1, a(7) = a(8) = a(9) = 2, and a(10) = 3.
		

Crossrefs

Programs

  • Python
    from sympy import isprime, nextprime; L = [4]
    def nexttwin(x):
        p1 = nextprime(x); t1 = p1 + 2
        while isprime(t1) == 0: p1 = nextprime(t1); t1 = p1 + 2
        return p1+1
    for _ in range(2, 89):
        print(len(L), end = ', ')
        t0 = L[-1]; t1 = nexttwin(t0); g0 = t1 - t0; M = [t1]; t = nexttwin(t1); g1 = t - t1
        while g1 < g0 and t - t1 <= g1: M.append(t); t1 = t; t = nexttwin(t)
        L = M