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

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
Showing 1-2 of 2 results.