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-10 of 10 results.

A340418 Indices in A339991 where records occur.

Original entry on oeis.org

1, 2, 3, 5, 7, 11, 19, 29, 39, 53, 61, 73, 79, 101, 149, 229
Offset: 1

Views

Author

Ya-Ping Lu, Jan 06 2021

Keywords

Comments

The records in A339991 corresponding the first 16 terms in this sequence are 0, 1, 4, 8, 9, 15, 22, 23, 24, 31, 32, 71, 88, 99, 104, 9267.
A339991(397), which is > 249275, is still unknown.
A339991(397) > 10^6. - Michael S. Branicky, Jan 09 2025

Crossrefs

Cf. A339991, A340008, A060412 (Collatz record indices).

Programs

  • Mathematica
    With[{s = Array[-1 + Length@ NestWhileList[Which[EvenQ@ #, #/2, PrimeQ@ #, #^2 - 1, True, # - 1] &, #, # > 1 &] &, 396]}, Map[FirstPosition[s, #][[1]] &, Union@ FoldList[Max, s]]] (* Michael De Vlieger, Feb 12 2021 *)
  • Python
    from sympy import isprime
    rec = -1
    for n in range(1, 397):
        m, ct = n, 0
        while m > 1:
            if m%2 == 0: m //= 2
            elif isprime(m) == 1: m = m*m - 1
            else: m -= 1
            ct += 1
        if ct > rec: print(n); rec = ct

A340008 a(n) is the image of n under the map: n -> n/2 if n is even, n-> n^2 - 1 if n is an odd prime, otherwise n -> n - 1.

Original entry on oeis.org

0, 1, 8, 2, 24, 3, 48, 4, 8, 5, 120, 6, 168, 7, 14, 8, 288, 9, 360, 10, 20, 11, 528, 12, 24, 13, 26, 14, 840, 15, 960, 16, 32, 17, 34, 18, 1368, 19, 38, 20, 1680, 21, 1848, 22, 44, 23, 2208, 24, 48, 25, 50, 26, 2808, 27, 54, 28, 56, 29, 3480, 30, 3720, 31, 62, 32
Offset: 1

Views

Author

Ya-Ping Lu, Dec 26 2020

Keywords

Comments

This map is used in A339991.

Crossrefs

Cf. A339991.

Programs

  • Mathematica
    Array[Which[EvenQ@ #, #/2, PrimeQ@ #, #^2 - 1, True, # - 1] &, 64] (* Michael De Vlieger, Dec 28 2020 *)
  • PARI
    a(n) = if (n%2, if (isprime(n), n^2-1, n-1), n/2); \\ Michel Marcus, Dec 26 2020
  • Python
    from sympy import isprime
    for n in range(1, 1001):
        if n%2 == 0: a = n/2
        elif isprime(n) == 1: a = n*n - 1
        else: a = n - 1
        print(a)
    

A340419 Trajectory of 397 under the map A340008: n -> n/2 if n is even, n-> n^2 - 1 if n is an odd prime, otherwise n -> n - 1.

Original entry on oeis.org

397, 157608, 78804, 39402, 19701, 19700, 9850, 4925, 4924, 2462, 1231, 1515360, 757680, 378840, 189420, 94710, 47355, 47354, 23677, 560600328, 280300164, 140150082, 70075041, 70075040, 35037520, 17518760, 8759380, 4379690, 2189845, 2189844, 1094922, 547461
Offset: 0

Views

Author

Rémy Sigrist, Jan 07 2021

Keywords

Comments

It is not known if this sequence reaches the value 1 and stops, or if it enters a cycle or diverges.

Examples

			a(0) = 397 is an odd prime, so a(1) = 397^2 - 1 = 157608.
a(1) = 157608 is even, so a(2) = a(1)/2 = 78804.
		

Crossrefs

Programs

  • PARI
    v=397; for (n=1, 32, print1 (v", "); v=if (v%2==0, v/2, isprime(v), v^2-1, v-1))

A346063 a(n) = primepi(A039634(prime(n)^2-1)).

Original entry on oeis.org

2, 1, 2, 2, 4, 3, 1, 5, 1, 6, 4, 3, 6, 4, 7, 14, 6, 10, 7, 37, 23, 25, 28, 18, 21, 22, 67, 24, 9, 46, 11, 19, 62, 12, 40, 24, 2, 27, 6, 91, 11, 31, 20, 1, 36, 203, 69, 25, 2, 80, 16, 48, 155, 18, 1, 326, 7, 20, 109, 365, 8, 39, 9, 240, 438, 2, 16, 154, 10, 17
Offset: 1

Views

Author

Ya-Ping Lu, Jul 03 2021

Keywords

Comments

This sequence looks at the effect on p^2 - 1 of A039634 with the primes represented by their indices. It seems that primes obtained by iterating the map A039634 on p^2 - 1 never fall into a cycle before reaching 2. Conjecture: Iterating the map k -> a(k) eventually reaches 1. For example, 1 -> 2 -> 1; 5 -> 4 -> 2 -> 1; and 27 -> 67 -> 16 -> 14 -> 4 -> 2 -> 1.
If the conjecture holds, then A339991(n) != -1 and A340419 is a finite sequence.

Crossrefs

Programs

  • Mathematica
    Array[PrimePi@ FixedPoint[If[EvenQ[#] && # > 2, #/2, If[PrimeQ[#] || (# === 1), #, (# - 1)/2]] &, Prime[#]^2 - 1] &, 70] (* Michael De Vlieger, Jul 06 2021 *)
  • Python
    from sympy import prime, isprime, primepi
    def a(n):
        p = prime(n); m = p*p - 1
        while not isprime(m): m = m//2
        return primepi(m)
    for n in range(1, 71): print(a(n))

Formula

a(n) = A000720(A039634(A000040(n)^2-1)). - Pontus von Brömssen, Jul 03 2021

A340801 a(n) is the image of n under the map f defined as f(n) = n^2 - 2 if n is an odd prime, f(n) = n/2 if n is even, and f(n) = n - 1 otherwise.

Original entry on oeis.org

0, 1, 7, 2, 23, 3, 47, 4, 8, 5, 119, 6, 167, 7, 14, 8, 287, 9, 359, 10, 20, 11, 527, 12, 24, 13, 26, 14, 839, 15, 959, 16, 32, 17, 34, 18, 1367, 19, 38, 20, 1679, 21, 1847, 22, 44, 23, 2207, 24, 48, 25, 50, 26, 2807, 27, 54, 28, 56, 29, 3479, 30, 3719, 31, 62
Offset: 1

Views

Author

Ya-Ping Lu, Jan 21 2021

Keywords

Comments

Conjecture 1: Iterating map f on an integer n (n > 1) results in a different integer, or f^i(n) != f^j(n) if i != j, where f^i(n) and f^j(n) are the i-th and j-th iterations of map f on n respectively.
Conjecture 2: An integer n eventually reaches 1 when map f is applied to n repeatedly.

Crossrefs

Programs

  • PARI
    a(n) = if (n%2, if (isprime(n), n^2-2, n-1), n/2); \\ Michel Marcus, Jan 22 2021
  • Python
    from sympy import isprime
    for n in range(1, 101):
        if isprime(n) == 1 and n != 2: a = n*n - 2
        elif n%2 == 0: a = n/2
        else: a = n - 1
        print(a)
    

Formula

a(2*k+1) = 2*a(2*k) if 2*k+1 is not a prime.
a(2*k+2) = a(2*k) + 1, where k >= 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

Views

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

A340420 The number of steps that n requires to reach 1 under the map: m -> m/2 if m is even, m-> 3*m + 1 if m is an odd prime, otherwise m -> m - 1. a(n) = -1 if 1 is never reached.

Original entry on oeis.org

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

Views

Author

Ya-Ping Lu, Jan 07 2021

Keywords

Comments

Conjecture: a(n) is never equal to -1.

Examples

			a(3) = 7 because 3*3 + 1 = 10 -> 10/2 = 5 -> 3*5 + 1 = 16 -> 16/2 = 8 -> 8/2 = 4 -> 4/2 = 2 -> 2/2 = 1 -> 1.
a(14) = 17 because 14 -> 7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1.
The 39 terms for a(n) <= 9 are given in the figure below.
145 288 12 42 13 80 133 264 260 258 255 512
  \  /   \  \  \ /    \ /    |   |   \  /
   144    6  21 40    132   130 129  256
     \     \   \ |     |     |    \  /
      72    3   20     66    65   128
        \     \ /       \     \   /
         36    10       33      64
           \     \        \    /
            18     5        32
               \     \     /
                 9      16
                   \    /
                      8
                      |
                      4
                      |
                      2
                      |
                      1
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=1, 0, 1 + a(
         `if`(n::even, n/2, `if`(isprime(n), 3*n+1, n-1))))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Jan 08 2021
  • Mathematica
    a[n_] := a[n] = If[n == 1, 0, 1 + a[
       If[EvenQ[n], n/2, If[PrimeQ[n], 3n+1, n-1]]]];
    Array[a, 100] (* Jean-François Alcover, Jan 30 2021, after Alois P. Heinz *)
  • PARI
    f(n) = if (n % 2, if (isprime(n), 3*n+1, n-1), n/2);
    a(n) = my(s=n, c=0); while(s>1, s=f(s); c++); c; \\ Michel Marcus, Jan 21 2021
  • Python
    from sympy import isprime
    for n in range(1, 101):
        ct, m = 0, n
        while m > 1:
            if m%2 == 0: m //= 2
            elif isprime(m) == 1: m = 3*m + 1
            else: m -= 1
            ct += 1
        print(ct)
    

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

Views

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

A341742 Nodes read by depth in a binary tree defined as: Root = 1; an even node N has a left child N + 1 if N + 1 is not a prime, and an odd node N has a left child sqrt(N + 2) if sqrt(N + 2) is a prime; the right child of a node N is 2*N.

Original entry on oeis.org

1, 2, 4, 8, 9, 16, 18, 32, 36, 33, 64, 72, 66, 65, 128, 144, 132, 130, 129, 256, 145, 288, 133, 264, 260, 258, 512, 290, 289, 576, 266, 265, 528, 261, 520, 259, 516, 513, 1024, 291, 580, 578, 1152, 267, 532, 530, 529, 1056, 522, 1040, 518, 517, 1032, 1026
Offset: 1

Views

Author

Ya-Ping Lu, Feb 18 2021

Keywords

Comments

Let d be the depth of a node N in the binary tree and f be the map of A340801. The d-th iteration of map A340801 on N gives 1, or f^d(N) = 1.
If Conjectures 1 and 2 made in A340801 hold, the sequence contains all positive integers and each integer appears once in the sequence.
The first odd prime does not appear until d reaches 30 and the first five odd primes appearing in the sequence are:
n a(n) d
------- ----- --
140735 4099 30
151872 1543 31
1574120 8689 36
1841645 2917 36
2111465 32771 36
The first two odd primes less than 100 appear in the binary tree are 17 at d = 4426 and 71 at d = 4421.

Examples

			The binary tree for depths up to 9 is given below.
  1
   \
    2
     \
      4
       \
        8
     /    \
   9       16
    \        \
    18        32
     \       /  \
     36    33    64
      \     \    / \
      72    66  65  128
       \     \   \   / \
      144   132 130 129 256
      / \   / \   \   \   \
   145 288 133 264 260 258 512
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    from math import sqrt
    def children(N):
        C = []
        if N%2 == 0:
            if isprime(N + 1) == 0: C.append(N+1)
        else:
            p1 = sqrt(N + 2.0); p2 = int(p1 + 0.5)
            if p2**2 == N + 2 and isprime(p2) == 1: C.append(p2)
        C.append(2*N)
        return C
    L_last = [1]; print(L_last)
    for d in range(1, 18):
        L_1 = []
        for i in range(0, len(L_last)):
            C_i = children(L_last[i])
            for j in range(0, len(C_i)): L_1.append(C_i[j])
        print(L_1); L_last = L_1

A346136 a(n) is the number of iterations that n requires to reach 1 under the map n -> A346063(n).

Original entry on oeis.org

0, 1, 2, 2, 3, 3, 1, 4, 1, 4, 3, 3, 4, 3, 2, 4, 4, 5, 2, 3, 9, 11, 8, 6, 10, 12, 6, 7, 2, 8, 4, 3, 6, 4, 10, 7, 2, 7, 4, 9, 4, 5, 4, 1, 8, 7, 6, 11, 2, 73, 5, 12, 5, 6, 1, 5, 2, 4, 34, 7, 5, 5, 2, 51, 7, 2, 5, 3, 5, 5, 3, 15, 6, 5, 2, 4, 10
Offset: 1

Views

Author

Ya-Ping Lu, Jul 05 2021

Keywords

Comments

Conjecture: the sequence is infinite.

Crossrefs

Programs

  • PARI
    f(x) = my(k=x^2-1); while(k>3 && !ispseudoprime(k), k\=2); k;
    a(n) = my(c=0, x=prime(n)); while(x>2, c++; x=f(x)); c; \\ Jinyuan Wang, Jul 15 2022
  • Python
    from sympy import prime, isprime
    for n in range(1, 78):
        m = prime(n); ct = 0
        while m > 2:
            if isprime(m): m = m*m - 1; ct += 1
            else: m //= 2
        print(ct)
    

Extensions

a(1) corrected by Jinyuan Wang, Jul 15 2022
Showing 1-10 of 10 results.